Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-29-2007, 10:03 PM   PM User | #1
michael180
Regular Coder

 
Join Date: Apr 2005
Posts: 313
Thanks: 18
Thanked 2 Times in 2 Posts
michael180 is an unknown quantity at this point
Bold, and italic?

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
michael180 is offline   Reply With Quote
Old 01-29-2007, 10:09 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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:
Code:
p:first-letter {font-style: oblique;}
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 01-29-2007, 10:31 PM   PM User | #3
Arbitrator
Senior Coder

 
Arbitrator's Avatar
 
Join Date: Mar 2006
Location: Splendora, Texas, United States of America
Posts: 2,906
Thanks: 5
Thanked 191 Times in 188 Posts
Arbitrator is on a distinguished road
Quote:
Originally Posted by michael180 View Post
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>
CSS:
Code:
span.firstWord { font-weight: bold; font-style: italic; }
__________________
Please for the love of god stop making IE. You current "browser"s cause me to cry every day. —Phil *
Arbitrator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:51 AM.


Advertisement
Log in to turn off these ads.