Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it okay to add id/class to <link> tag?

Tags:

html

Is it okay to do this?

<link rel="stylesheet" href="css/mobile/load.css" id="stylesheet_mobile" /> 

so I can use JavaScript to dynamically disable stylesheets?

like image 669
AlexCheuk Avatar asked Apr 09 '12 17:04

AlexCheuk


People also ask

Can I use class and ID in same tag?

Yes, you can. But note that Id's must be unique within your html file, while classes can be used in multiples elements.

Can we use ID and class together in HTML?

Your HTML there is fine. You can specify a class and an id on the same element.

Can you add class to a tag?

To add a class on click of anchor tag, we use addClass() method. The addClass() method is used to add more property to each selected element. It can also be used to change the property of the selected element.

Is it better to use ID or class in HTML?

The basic rule that you need to keep in mind while using classes and ids in CSS is that, id is used for single elements that appear on the page for only once (e.g. header, footer, menu), whereas class is used for single or multiple elements that appear on the page for once or more than once (e.g. paragraphs, links, ...


1 Answers

According to HTML 4.01 Transitional, id, class are document-wide selectors, and thus it is ok to have them in the link element.

like image 129
xbonez Avatar answered Sep 27 '22 18:09

xbonez