Problem definition
attribute id values HTML5 vs HTML4.01,
Are below values are valid for id attribute??
<p id="♥">First Value.
<p id="©">Second Value.
<p id="{}">Third Value.
Solution
The HTML 4.01 spec states that ID tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), colons (:), and periods (.). For the class attribute, there is no such limitation. Class names can contain any character, and they don’t have to start with a letter to be valid.
HTML5 gets rid of the additional restrictions on the id attribute. The only requirements left — apart from being unique in the document — are that the value must contain at least one character (can’t be empty), and that it can’t contain any space characters.
This means the rules that apply to values of class and id attributes are now very similar in HTML5.
Example
Valid for HTML5
Invalid for HTML4.01
<p id="♥">First Value.
<p id="©">Second Value.
<p id="{}">Third Value.
Valid for HTML5
Valid for HTML4.01
<p class="♥">First Value.
<p class="©">Second Value.
<p class="{}">Third Value.
attribute id values HTML5 vs HTML4.01,
Are below values are valid for id attribute??
<p id="♥">First Value.
<p id="©">Second Value.
<p id="{}">Third Value.
Solution
The HTML 4.01 spec states that ID tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), colons (:), and periods (.). For the class attribute, there is no such limitation. Class names can contain any character, and they don’t have to start with a letter to be valid.
HTML5 gets rid of the additional restrictions on the id attribute. The only requirements left — apart from being unique in the document — are that the value must contain at least one character (can’t be empty), and that it can’t contain any space characters.
This means the rules that apply to values of class and id attributes are now very similar in HTML5.
Example
Valid for HTML5
Invalid for HTML4.01
<p id="♥">First Value.
<p id="©">Second Value.
<p id="{}">Third Value.
Valid for HTML5
Valid for HTML4.01
<p class="♥">First Value.
<p class="©">Second Value.
<p class="{}">Third Value.
Tags and Related topics
html vs html5 valid values for id attribute,
naming convention for attribute id html,
This article is uploaded by RayMn & BR Technologies Pvt Ltd
html vs html5 valid values for id attribute,
naming convention for attribute id html,
This article is uploaded by RayMn & BR Technologies Pvt Ltd
No comments:
Post a Comment