From https://www.w3schools.com/tags/att_global_id.asp:
In HTML5, the id attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).
I'm making a browser-based application for internal use, which in one of the pages there is no CSS or JavaScript referring to any element of the page - just tables.
Should I still specify the id attribute for the elements though there is no (not yet) need to use it? Or it is just best practice to put id'entifiers for future use?
Definition and Usage The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document). The id attribute is most used to point to a style in a style sheet, and by JavaScript (via the HTML DOM) to manipulate the element with the specific id.
The ID and NAME elements must start with a letter i.e. upper case A to Z or lower case a to z; a number is not allowed. After the first letter any number of letters (a to z, A to Z), digits (0 to 9), hyphens (-), underscores (_), colons (:) and periods (.) are allowed.
The id global attribute defines an identifier (ID) which must be unique in the whole document. Its purpose is to identify the element when linking (using a fragment identifier), scripting, or styling (with CSS).
Attributes are always specified in the start tag (or opening tag) and usually consists of name/value pairs like name="value" . Attribute values should always be enclosed in quotation marks.
Only put required elements or attributes in HTML.
You do not need to put ID attribute if it is not required, and you can always add ID attribute whenever required.
Keeping only required elements in html will make it easy to read, clean, low on size and hence improves performance and speed.
No, it is not necessary. It is required only when you have to access any form control uniquely on a web page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With