+ 2
How can you combine an HTML class, element and attribute together in CSS styling? E.g. Can we have something like .header div {}
HTML and CSS
2 Respostas
+ 2
Yes you can combine HTML class with HTML own tag and element. For example, if you want to target <header> tag and also class inside it. Let me give ex :
Ex :
<header>
<div class ="ex-class">
<h1> this is example </h1>
</div>
</header>
You can style in CSS like :
header .ex-class {
}
Or
header .ex-class h1{
}
But if you want to specify what's in div tag, i suggest to use class instead so it wouldn't be too confusing
+ 1
I don't say you Can't do that. You still can target div in CSS by calling it without class or id. But I recommend to use class instead. You can also target it by id too.