Web Design Lesson 003 b – HTML Attributes

HTML Attributes

Attributes specify the addition of special features to HTML elements.

Attributes need to be specified in the start tag. Each attribute has a name and can be assigned a value. Format of adding attributes is as below:

<start_tag attribute1_name optional[=attribute1_value] attribute2_name optional[=attribute2_value] >

The following code demonstrates setting of two attributes “name” and “value” in the HTML Element button.The value set for the attributes
can be single quoted or double quoted. It can be unquoted too but not considered good programming practice.

<html>
<head> </head>
<body> 
<button name="btn1" value="button"> OK </button>

</body>
</html>

If the attribute value itself contains a quote, you need to enclose the value within the second type of quote.

<button name="bt'n1"> OK </button>
<button name='bt"n1'> OK </button>

Leave a Reply

Your email address will not be published. Required fields are marked *