...

View Full Version : css h1 color



croatiankid
07-06-2006, 03:09 PM
can i use only css to make the first word in a <h1> blue and the rest green, or do i have to use <span>s?

mylegoh
07-06-2006, 03:20 PM
I have not come across pseudo for word ie. h1:first etc. so i guess you will have to use span.
Hope this helps.

ragol_67
07-06-2006, 04:52 PM
Try this:




<html>
<head>
<style type="text/css">
.first-word
{
color: blue;
font-size:xx-large
}
h1
{
color: green;
}
</style>
</head>

<body>
<h1>
<span class="first-word">You</span> cannot use the :first-letter pseudo-element to add a special effect to the first word of a text!
</h1>
</body>

</html>





Nick!

Bill Posters
07-06-2006, 04:56 PM
first word(emphasis added)

ragol_67
07-06-2006, 04:59 PM
Oh oops! Sorry, my bad. It's too early for me! :rolleyes:


*!Adjusts Code!*

felgall
07-06-2006, 10:59 PM
Why not just use

h1:first-word {color:blue;}

or do you still have too many visitors using antique web browsers for that method (now several years old) to work.

Bill Posters
07-06-2006, 11:16 PM
Why not just use

h1:first-word {color:blue;}

or do you still have too many visitors using antique web browsers for that method (now several years old) to work.
Antiquated like FF1.5/Mac, Safari, Camino and Opera 9/Mac (none of which appear to support that particular option)?

Maybe I've developed some CSS standards blind-spots, but alleged support the :first-word pesudo element being several years old is a new one on me.
I've not found anything beyond it's discussion as a potential inclusion for CSS3.

Which super-new browser did you have in mind that supports it?

Kravvitz
07-07-2006, 02:21 AM
felgall, I don't see :first-word mentioned in the latest working draft of the CSS3 Selectors module (http://www.w3.org/TR/css3-selectors/) either.

Here's a JavaScript solution to this problem: First Word Selector (http://www.dynamicsitesolutions.com/javascript/first_word_selector/)

felgall
07-07-2006, 02:48 AM
I guess that the CSS books that came out several years ago that included it were getting a little ahead of themselves. I have never had a use for it but just assumed that since books several years old included it as one of the standard stylesheet options that current browsers supported it. I shal;l try not to make similar assumptions in the future.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum