Before I started using CSS. If I wanted to make the first word in a particular sentence bold or italic, I would use the <b> and <i> tags. Is there a way I can achieve this affect with CSS. When I use <b> or <i> tags, I can't get my page to validate?
As far as I know b and i are still valid in strict (X)HTML but you can achieve the effect by using semantically neutral span elements and applying styles to these elements through CSS.
If it's just the first letter that is supposed to be styled you can use the :first-letter pseudo class:
Location: Splendora, Texas, United States of America
Posts: 2,906
Thanks: 5
Thanked 191 Times in 188 Posts
Quote:
Originally Posted by michael180
If I wanted to make the first word in a particular sentence bold or italic, I would use the <b> and <i> tags. Is there a way I can achieve this affect with CSS.
I don’t think that this is possible with current or planned CSS. You’d have to touch the structural (HTML) markup:
HTML:
Code:
<p><span class="firstWord">Welcome</span> to my world.</p>