The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Which is better attribute selector or using 2 classes?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #270275

    Hey guys,

    Using the Icomoon app you can choose to use an attribute selector such as [class^=”icon-“] or a class name.

    My question is, which is better using the attribute selector or using 2 class names (ex: .icon .icon-help) ?

    Is there a way to test CSS selector performance? and not just how fast a page loads?

    Super Mario


    So if you have the classes in something that looks like this…

    <i class="icon icon-magic"></i>

    …specificity and performance between the selectors [class^=”icon-“] and .icon are pretty much the same.

    I would use .icon mainly because its easier to read organize when you set your styles for all the different icons. Check out what I mean below:

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.