Quote:
Originally Posted by roger64
Code:
.firstletter:first-letter {color:red;}
does the same trick for the first letter of a paragraph.
|
Only for paragraphs (or any other element) with class="firstletter".
Quote:
Question: I would like to insert a CSS code which gives a
Code:
class="firstletter"
to the first paragraph of each h1 title. Or maybe I need a regex for that? I am confused.
|
You can use selectors:
Code:
h1 + p:first-letter {color:red;}
This makes red the first letter or any paragraph immediately following an h1, whatever their classes are.
But, even if first-letter is supported, it's not flexible enough (for my needs), especially regarding punctuation preceding the first letter (think quotation marks, dashes, or Spanish question/exclamation marks), and cases where you need to use another element for the text following the first letter.