Who cares? # header.h1 Vs: #header h1

I am trying to access the h1 element inside a div with the identifier "header".

Should i use

#header h1 

or

 #header.h1 
+4
source share
2 answers
 #header h1 

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

 #header.h1 

Means "element with id" header ", which also has class name h1" (you definitely don't need this one).

 #header > h1 

Means β€œall h1 elements that are direct child elements (that is, directly below it) with aβ€œ header ”element. This type of selector is not supported by IE6. This may work, but you probably want to get the first one.

+15
source
 #header h1 

if you add a dot to the value, this is the class name

help link:

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

+1
source

All Articles