HTML 5 Programming and Web development/HTML 5 Attributes

From Wikibooks, open books for an open world
Jump to navigation Jump to search

HTML 5 attributes are created using a name-value pair and are usually put alongside the tag name.

Name-value pairs[edit | edit source]

Name-value pairs are represented by a set of text strings in which name="value" and are usually separated by commas,semicolons,space or newline character.

Writing HTML 5 Atrributes[edit | edit source]

HTML 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.

What do Attributes do[edit | edit source]

Attributes give extra information about an element for example in the input element the attribute type gives the type of input, so if he had type="button" we would get a button instead of a textbox.Attributes are very important to HTML and without them Web development would be probably much harder.

Special Attributes[edit | edit source]

HTML 5 has some special attributes that I must point out.

The Id Attribute[edit | edit source]

The Id attribute is a unique Identifier for the element.The Id property becomes very useful when using CSS and JavaScript.An example of the Id Attribute.

<form id="htm_form">

The name Attribute[edit | edit source]

The name Attribute specifies a name for an element.Conventionally groups if elements can have the same name.

The class attribute[edit | edit source]

This specifies the style class under which an element falls. NB:An Attribute can also be called a property