+ 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

24th Jul 2020, 3:01 AM
Ogunleke Samuel Ayomide
Ogunleke Samuel Ayomide - avatar
2 odpowiedzi
+ 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
24th Jul 2020, 3:22 AM
Noviyana
Noviyana - avatar
+ 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.
24th Jul 2020, 3:26 AM
Noviyana
Noviyana - avatar