Guest Sqwee Posted March 4, 2006 Share Posted March 4, 2006 Sorry...I'm kind of new to CSS...Is there a way to set a universal text color? I know how to set p, h1, h2 (ect), all individually, but is there a way to do them all at once (all the same color)?Thanks a whole heap for any help! Link to comment Share on other sites More sharing options...
newbman Posted March 4, 2006 Share Posted March 4, 2006 you can do thish1, h2, h3, h4, h5, h6, p, td, div, span, etc. etc.{color:#xxxxxx} Link to comment Share on other sites More sharing options...
Tynian Posted March 4, 2006 Share Posted March 4, 2006 you can do thish1, h2, h3, h4, h5, h6, p, td, div, span, etc. etc.{color:#xxxxxx}<{POST_SNAPBACK}> Yeah that's good, but if you want to add différent option in each of them also, that make a crazy code. Link to comment Share on other sites More sharing options...
Err Posted March 4, 2006 Share Posted March 4, 2006 you mean like this? html, body { color: red;}h1, h2, h3 { color: blue;} Link to comment Share on other sites More sharing options...
mpoer Posted March 4, 2006 Share Posted March 4, 2006 why not body { color:#xxxxxx; } that will set all the color within the body element to the specified color. Then, of course, something like h1 {color:#yyyyyy;} would over-ride the original font color of xxxxxx and use yyyyyy.Is that what you were looking for? Link to comment Share on other sites More sharing options...
sbrownii Posted March 4, 2006 Share Posted March 4, 2006 As mpoer says, if you set the color on an element, it child elements automatically inherit that color. The exception would be the <a> element, which the browser by default will display in a way that makes it easy to know it is a link.If you want to set the same color for ALL elements you can use the universal selector. You can use it in combination as you would with any other selector.http://css.maxdesign.com.au/selectutorial/...s_universal.htmhttp://www.dithered.com/css_filters/css_on...l_selector.htmlThe following will give you some idea of what can be done with the universal selector <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title></title><style type="text/css">*{color:green;}body{color:red;}div *{color:yellow;}a {color:red}span {color:purple}</style></head><body>body<h1>H1</h1><div>div1</div><div>div2<p>p1</p><p>p2</p><a href="#">a2</a><span>span1<p>p3</p><a href="#">a2</a></span></div></body></html> Link to comment Share on other sites More sharing options...
mpoer Posted March 4, 2006 Share Posted March 4, 2006 another good point, sbrownii.And I just realized that W3schools doesn't say anything about the universal selector!Sqwee, have we answered your question? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now