...

View Full Version : Bold, and italic?



michael180
01-29-2007, 11:03 PM
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?

Thanks

VIPStephan
01-29-2007, 11:09 PM
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:


p:first-letter {font-style: oblique;}

Arbitrator
01-29-2007, 11:31 PM
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:

<p><span class="firstWord">Welcome</span> to my world.</p>

CSS:

span.firstWord { font-weight: bold; font-style: italic; }



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum