Search within TutorialsPark

HTML Attributes.


HTML attributes denote the information about the content.


HTML Attribute.

1.HTML attributes provide information about the content rather than itself being the content

2.Many HTML elements have multiple types of attributes to denote various kinds of information related to the document. Eg: href="..", src=".."

3.Usually the attributes come in form of name and value pairs. Eg: href="URL" (href(name) and URL(value)).

4.The Attributes must be added only to the start tags of the element.Never should an attribute be added to the end tags.

<a href="tutorialspark.com" > Tutorials park </a> Correct

<a> Tutorials park </a href="tutorialspark.com"> Incorrect

HTML Attribute example.

Give it a TRY! »


Attributes: Rules and Values

Fig: Attribute comprises of name and value pairs

RULE 1:   Attribute should appear in the start tag only and never in the end tags.
Eg : <a href="Tutorialspark.com" > Tutorials park </a>

RULE 2:   Attribute name should be linked to the value using equal sign (=).
Eg : href="Tutorialspark.com"

RULE 3:   Attribute value should always appear within the quotes. Either single quotes ( '...') or double quotes( " ... "), both are legal.

RULE 4:   Attributes name and value are case sensitive.W3C recommends that they should always be in lowercase.


Note-If an attribute value itself comprises of quotes you can use any of the styles.Eg: "Your 'quote' is here" or 'your "quote" is here'

Boolean Attributes.

1.Boolean attributes do not require any value,just provide the attribute name and you are done.Eg:.

<audio loop controls> </audio>

2. In the above example the attributes loop and controls are boolean attributes, they require no value.

Boolean attribute example:

Give it a TRY! »


HTML Custom attributes.

1. Custom attributes are defined by the users, they also called as data-attributes. Eg:

<audio data-music="inception"> </audio>

2. Custom attributes are of form "data-*", here "*"can be any custom name but must be prefixed with "data".

Boolean attribute example:

Give it a TRY! »


HTML Multiple Attributes.

1. A given HTML element can have multiple attributes, there is no limit to the no of attributes an element can have. Eg:

<a src="tutorialspark.com" class="name" id="HTML5" > </a>

2. The order and nature(i.e local or global) of attribute does not matter.

Note-Multiple attributes must be separated with one or two whitespaces in between.