Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference? #header.h1 Vs: #header h1

Tags:

css

I'm trying to access the h1 element inside a div with an id of "header".

Should I use

#header h1

or

#header.h1
like image 676
brian Avatar asked Jun 28 '09 18:06

brian


2 Answers

#header h1

Means "all h1 elements that are descendants of the element with the id "header" (you probably want this one).

#header.h1

Means "the element with the id "header" that also has the class name h1" (you definitely don't want this one).

#header > h1

Means "all h1 elements that are direct children of (i.e., directly underneath) the element with the id "header". This type of selector is not supported by IE6. This one may work but you probably want the first one.

like image 109
Matt Bridges Avatar answered Oct 12 '22 22:10

Matt Bridges


#header h1

if you add point before the meaning is this is a class name

help link :

http://www.w3schools.com/CSS/css_syntax.asp

like image 26
Haim Evgi Avatar answered Oct 12 '22 23:10

Haim Evgi