HTML 5 Programming and Web development/HTML 5 Attributes
HTML 5 attributes are created using a name-value pair and are placed after the tag name.
Name-value pairs
editName-value pairs are represented by a set of text strings in which name="value"
are usually separated by commas, semicolons, space or newline character.
Writing HTML 5 Atrributes
editHTML 5 attributes are written inside the element's tag and separated by spaces. For example:
<input type="text" value="hello Web"/>
In this code the attributes are type and value and their values are "text" and "hello Web" respectively.
Attributes give extra information about an element. For example, in the input element the attribute type gives the type of input, so if we had type="button"
we would get a button instead of a textbox. Attributes are very important in HTML and without them Web development would probably be much harder.
Special Attributes
editHTML 5 has some special attributes that I must point out.
The id attribute
editThe id attribute is a unique identifier for the element. It becomes very useful when using CSS and JavaScript. You cannot have more than one element with the same id on a web page. Here is an example of the id attribute:
<form id="htm-form">
</form>
The class attribute
editThe class attribute groups an element with other elements of the same class. This is often used to apply CSS styles to elements. Unlike with the id attribute, you can have more than one element with the same class on a page.