When creating the id
attributes for HTML elements, what rules are there for the value?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
No spaces, must begin with at least a char from a to z and 0 to 9.
Also, never forget that an ID is unique. Once used, the ID value may not appear again anywhere in the document.
You may have many ID's, but all must have a unique value.
On the other hand, there is the class-element. Just like ID, it can appear many times, but the value may be used over and over again.
From the HTML 4 specification:
A common mistake is to use an ID that starts with a digit.
HTML5
Keeping in mind that ID must be unique, ie. there must not be multiple elements in a document that have the same id value.
The rules about ID content in HTML5 are (apart from being unique):
This is the W3 spec about ID (från MDN):
More info:
id
)id
)To reference an id with a period in it you need to use a backslash. Not sure if its the same for hyphens or underscores. For example: HTML
CSS