There are many new elements in HTML5, such as main, header, article, section etc.
Is is good idea to not give these elements an id or class?
For example: I have only one main element on the page. Is it a bad idea to give it an id or class?
There are many new elements in HTML5, such as main, header, article, section etc.
Is is good idea to not give these elements an id or class?
For example: I have only one main element on the page. Is it a bad idea to give it an id or class?
For example: I have only one main element on the page. Is it a bad idea to give it an id or class?
It depends
Consider this:
You are using multiple pages,
all pages have one main element each,
but all are linked to one single CSS file,
but you want all main to have some different styling...
You should probably use id here
in any other case where page has only one element of a certain tag and has it's own seprate css it's redundant to use ids or classes
You don't need to give an id to an element which occurs only once in your code, as the id can not be used multiple times. If you have only one header tag, do not give it an id, just operate directly on this tag.
class will of course be handy if you'd assign it to multiple elements on your webpage.
I think we should use classe for reuse code because ID can't be used more (in page). However, in your case id can wise because there is one element.
For more information, there are great article: css-tricks stackoverflow