{"id":14192,"date":"2013-02-14T20:03:57","date_gmt":"2013-02-15T03:03:57","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14192"},"modified":"2020-06-18T07:53:39","modified_gmt":"2020-06-18T14:53:39","slug":"first-letter","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/selectors\/f\/first-letter\/","title":{"rendered":"::first-letter"},"content":{"rendered":"\n
The result is as if you had a faux element around the first letter:<\/p>\n\n\n\n T<\/span>he first letter is bold and red<\/p>\n\n\n\n::first-letter<\/code> is a pseudo element which allows you to style the first letter in an element, without needing to stick a <span> tag around that first letter in your HTML. While no tags are added to the DOM, it is as if the targeted first letter were encompassed in a
<\/code> tag. You can style that first letter as you would a real element with:<\/p>\n\n\n\n
p::first-letter {\n font-weight: bold;\n color: red;\n}<\/code><\/pre>\n\n\n\n
<p>The first letter is bold and red<\/p><\/code><\/pre>\n\n\n\n
<!-- Just an example, does not work! -->\n<p>\n <firstletter>T<\/firstletter>he first letter is bold and red.\n<\/p><\/code><\/pre>\n\n\n\n
display: inline;<\/code> elements.)<\/li>
::first-letter<\/code> and
::first-line<\/code> on an element, the first letter will inherit from the first line styles, but styles on the
::first-letter<\/code> will overwrite when styles conflict.<\/li>
::before<\/code>, the first letter or punctuation character, whether it’s part of the original text node or created with generated content, will be the target.<\/li><\/ul>\n\n\n
More Information<\/h3>\n\n\n