Jump to content
N-Europe

Trying to get my head around this simple css # thing...


The Lillster

Recommended Posts

I'm currently making a new website and i'm designing it using css. But I can't seem to get my head around how this # thing works...

 

Example What's the different between.

 

 

div#header {

background-image:url(images/top_grad.jpg);

background-repeat:repeat-x;

}

 

And

 

#header {

background-image:url(images/top_grad.jpg);

background-repeat:repeat-x;

}

 

As you can see the 1st one has the div before the # but the 2nd one doesn't.

 

My question is, does it matter if the div part is there or not, or is it just there to make things more understandable?

Link to comment
Share on other sites

If you put div#header then

 

<div id="header"> will have the header style but

 

<span id="header"> (or anything else) will not.

 

Whereas if you just use #header on its own, anything that you give the header ID to will get that style attribute.

Link to comment
Share on other sites

×
×
  • Create New...