How to target headings for a specific div ID?

岁酱吖の 提交于 2019-12-08 19:20:59

问题


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!


回答1:


I think you must do so:

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



回答2:


You need to target all hN with the ID.

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

See Fiddle



来源:https://stackoverflow.com/questions/21051687/how-to-target-headings-for-a-specific-div-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!