HTML Attributes

HTML Attributes are additional informations to tags. Let us understand with an example. We already know the body tag. Everything between <body> and </body> appears on the browser. Let us assume that we want to change the background color. We can do so by adding the attribute to the body tag as in following example.

<body  bgcolor="yellow">
<p>An example to show how to add attribute to the body tag.</p>
<p>By Adding the bgcolor to the body we can change the background color.</p>

Example - Attribute

Attributes come in name/value pairs like this: name="value". In the example above bgcolor was the name of the attribute and yellow is its value. The attribute name and values are case sensitive. It is however, recommended that we use the lowercase.

Attributes values should always be quoted in either double quote or single quotes. Double quotes are more frequently used. Howerver if you want to assign a value that need to have double quotes, then you will have to use single quote. For example

att_name = 'outside "inside" outside'