How to target headings for a specific div ID?
Asked Answered
C

2

8

I am trying to style all the headings in my header with a different font-family than the headings on the rest of the page but I am having trouble getting the style to only apply to the specific header ID.

Here is what I tried:

#header h1,h2,h3,h4 {
    font-family:'Helvetica';
}

But this causes all h1/2/3/4 tags to use the Helvetica font regardless of if they are in the header div or not. I'm sure I am missing something simple, can anyone help? Thanks!

Call answered 10/1, 2014 at 18:27 Comment(1)
Do I have to add #header before each? Like #header h1, #header h2, etc.?Call
H
13

I think you must do so:

#header h1,#header h2, #header h3, #header h4 {
    font-family:'Helvetica';
}
Holifield answered 10/1, 2014 at 18:28 Comment(0)
K
3

You need to target all hN with the ID.

#header h1, 
#header h2, 
#header h3, 
#header h4 {
    font-family:'Helvetica';
}

See Fiddle

Kor answered 10/1, 2014 at 18:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.