Thread: :firstletter
View Single Post
Old 12-07-2014, 09:11 AM   #3
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,550
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by roger64 View Post
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.
Jellby is online now   Reply With Quote