In CSS3, you can use the ":first-letter" selector and color attribute to modify the color of the first letter. The syntax is "element:first-letter{color:color value;}"; ":first-letter" The first letter of the element can be selected, and color can set the text color for the selected letter.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css3 Modify the initial letter color
Implementation idea:
Use ": The first-letter" selector selects the first letter of the element
Use the color attribute to modify the text color of the selected letter.
TheColor property can specify the color of the text.
Implementation code:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> .first { width: 200px; height: 100px; border: 1px solid red; } .first p::first-letter { color: red; } </style> </head> <body> <div class="first"> <p>aksadjklahkljasklf</p> </div> </body>
Extended knowledge:
:The first-letter selector can use the following attributes:
font
css video tutorial, web front-end)
The above is the detailed content of How to change the color of the first letter in css3. For more information, please follow other related articles on the PHP Chinese website!