CSS Pseudo Element นี้เลือกตัวอักษรตัวแรกของเนื้อหาขององค์ประกอบ อย่างไรก็ตาม สิ่งนี้ใช้ไม่ได้หากองค์ประกอบอยู่ในระดับอินไลน์
ตัวอย่าง
มาดูตัวอย่าง CSS ::first-letter pseudo element −
<!DOCTYPE html>
<html>
<head>
<style>
div{
background-color: #32485d;
border: 5px solid black;
color: #959799;
}
p::first-letter {
font-size: 1.5em;
color: #f9f9f9;
padding: 2px;
}
</style>
</head>
<body>
<div>
<h2>Eclipse IDE</h2>
<p>"Eclipse is an integrated development environment (IDE) for Java and other programming languages
like C, C++, PHP, and Ruby etc. Development environment provided by Eclipse includes the Eclipse Java
development tools (JDT) for Java, Eclipse CDT for C/C++, and Eclipse PDT for PHP, among others."</p>
</div>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

ตัวอย่าง
มาดูตัวอย่างอื่นของ CSS ::first-letter pseudo element −
<!DOCTYPE html>
<html>
<head>
<style>
p::first-letter {
font-size: 1.5em;
background-color: black;
color: #dc3545;
padding: 2px;
}
</style>
</head>
<body>
<div>
<h2>Machine Learning Tutorials</h2>
<p>TensorFlow</p><p>Machine Learning with Python</p><p>Time Series</p><p>PyTorch</p>
</div>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
