Forum Moderators: not2easy
:first-line is out I don't want to style the entire first line.
I also don't want to use a <span> tag. (I hate that damn thing.)
Ideally I'll be able to style everything in the first line up to the first punctuation mark.
I'm thinking maybe CSS pattern matching, variables, or regular expressions might work, but I have no idea—that's really out of my depth.
So far my inadequate searching skills have found nothing of value. :(
Any suggestions about where to look, how to search, or even a full-blown solution is much appreciated.
Thanks
Does anyone know of a method I can use CSS to style the first sentence of a paragraph?
There is no pure CSS way of doing this
I also don't want to use a <span> tag. (I hate that damn thing.)
Why?
I'm thinking maybe CSS pattern matching, variables, or regular expressions might work, but I have no idea—that's really out of my depth.
You have two choices; you can either add an element around the first sentance using either Javascript or a server side language when used in conjunction with regex. Then the element that's been created can by styled with CSS.
If you don't like span, use a semantic tag and style it.
<strong class="first-sentence">This is it man.</strong> ......
or
<p class="intro"><strong>make sure this is the only strong.</strong>.....</p>
...
p.intro strong { /* your style */ }
Strong gives it semantic meaning, the class styles it.
This is actually what spans are for, aren't they?
Yes, in this context, the use of SPANs are perfectly acceptable as a substution for a pattern-matching pseudo element that doesn't exist.
If you don't like span, use a semantic tag and style it.
Whereas a plain SPAN is a semantically neutral element, the STRONG element should only be used when you want to place a strong emphasis on that content.
However, you still don't give a reason why you "hate that damn thing [SPAN element]"...