2

I've inspected the code of https://highlightjs.org/.

In between the ... i've found a suspicous class attribute assigned to a tag. For example:

<link class="codestyle" rel="stylesheet" href="/static/styles/default.css" disabled="">

Google and the MDN truned out to be not helpful. Instead the MDN didn't even list the class attribute as possible attribute for a tag.

Does it have any effect?

tmuecksch
  • 6,222
  • 6
  • 40
  • 61
  • Adding a class to an element classifies it as belonging to that class, period. That is _all_ a class _ever_ does. – CBroe Sep 12 '14 at 08:53
  • possible duplicate of [Is it okay to add id/class to tag?](http://stackoverflow.com/questions/10077475/is-it-okay-to-add-id-class-to-link-tag) – Dipak Sep 12 '14 at 08:55
  • 1
    "Instead the MDN didn't even list the class attribute as possible attribute for a tag." That's because the class attribute can be applied to any element, so it would be redundant to list it for all elements. – BoltClock Sep 12 '14 at 09:03
  • 1
    As mentioned at the top of the attributes section: http://note.io/1syJpCp – Quentin Sep 12 '14 at 09:10

2 Answers2

3

Is it common to assign class attribute to <link>?

No.

What is it's effect?

The same as for any other element.

It makes it a member of a class so it can be identified as part of a group by languages/apis that include a means to access elements via their class (such as CSS, DOM and XPath).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

It's there to make it easier to query alternate stylesheets in the script that switches style of a snippet. Look at line #14 of the page source.

isagalaev
  • 1,173
  • 11
  • 16