Mutley Posted January 18, 2007 Share Posted January 18, 2007 Is there any difference between doing a . or # when using CSS? For example:HTML:[code]<p class="text">blah</p>[/code]CSS:[code].text {color:#000000;}[/code]OR...[code]#text {color:#000000;}[/code] Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted January 19, 2007 Share Posted January 19, 2007 a "." is for a class, you can use this as much as you want in one pagea "#" is for an id, you can only use this once on each page<div id="wrapper"><div class="green">This is green text</div><div class="green">This is green text</div><div class="green">This is green text</div></div>I didn't include the css...but I think you'll get the idea.-Chris Quote Link to comment Share on other sites More sharing options...
bibby Posted January 21, 2007 Share Posted January 21, 2007 To go a little further,Say you had a generic class called red[code].red{ background-color:#902100;}[/code][code]<li class="red"></li> ..<td class="red"></td> ..<span class="red"></span> ..<span class="blue"></span> ..[/code][list][*]You code apply that to many types of tags.[/list]If you wanted to beforehand in the css, you could call them out by tag and id. [code]span .red{ font-size:1.6em; }[/code][list][*]This line only effects spans that are "red"[/list][i]tag & class[/i] are one way to further divide class and id. It all depends on how many children you want your elements to have. Inheritence.I try to use classes for things that I'll most likely reuse, and ids for the known one-timers.That said, the more I use javascript, the more that I'm dropping [b]id[/b]s all over the place. I'll try to find a way to style away from the script. The last thing you need is style and javascript breaking together. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.