tmuecksch
tmuecksch

Reputation: 6652

Is it common to assign class attribute to <link>? What is it's effect?

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?

Upvotes: 2

Views: 38

Answers (2)

isagalaev
isagalaev

Reputation: 1213

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.

Upvotes: 1

Quentin
Quentin

Reputation: 944442

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).

Upvotes: 3

Related Questions