Jump to content

setting a universal text color


Guest Sqwee

Recommended Posts

Guest Sqwee

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

you mean like this?

html, body {  color: red;}h1, h2, h3 {  color: blue;}
Link to comment
Share on other sites

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...