{"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

::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

The result is as if you had a faux element around the first letter:<\/p>\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

T<\/span>he first letter is bold and red<\/p>\n\n\n\n