2

What would be the proper CSS selector to target the following tag:

<nav class="twelve-col col main-menu">

Would the proper selector just be:

.twelve-col col main-menu {
}
0

3 Answers 3

3

No. You should combine individual class names using .:

.twelve-col.col.main-menu
9
  • Ah, i see. Now does it matter in the css if it says <nav class="twelve-col col main-menu"> or <div class="twelve-col col main-menu"> Commented Jul 16, 2017 at 15:51
  • If it says what? :) I mean, what do you mean? Both are same no? Commented Jul 16, 2017 at 15:51
  • Sorry, refresh the page - I was editing - sorry Commented Jul 16, 2017 at 15:52
  • ok so it wouldnt be .nav.twelve-col.col.main-menu { Commented Jul 16, 2017 at 15:52
  • @BillWentworth It's not .nav. but it's just nav. for Tag Selectors. . is used for classes and # is used for ids. Commented Jul 16, 2017 at 15:53
0

The most effective selector will be nav.twelve-col.col.main-menu you can also use nav.main-menu which makes some sense.

0
0

No. Your selector is trying to find main-menu INSIDE col which is INSIDE twelve-col. But you are looking for element, that has twelve-col col main-menu classes the same time, so use .twelve-col.col.main-menu

However try BEM methodology, where you use just one class to make all your selectors same specificity (http://getbem.com)

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.