Attributes are “name-value” pair, changes the behavior of HTML Elements. Attributes
always used with HTML element start tag or opening tag.
HTML Attributes are of 4 types:
- Required Attributes
- Optional Attributes
- Standard Attributes
- Event Attributes
1) Required Attributes: HTML Elements need attributes to work properly
Example:
<input type="submit" value="Post" />
2) Optional Attributes: changes the behaviour of HTML Elements.
Example:
<div style="border:1px solid black;">Hello world</div>
3) Standard Attributes: Attributes that are common to all HTML Elements also called as
Global Attributes
Example:
class, id, accesskey, data, title etc.
4) Event Attributes: Attributes which invokes javascript function, when user interact with specific HTML element.
Example:
onclick, onblur, onfocus, onload, onkeyup etc.
HTML 5 does not require double qoutes arround its value.
Example:
<html>
<head>
</head>
<body>
<div align="right">
Hello World....
</div>
<a href="" title="Click to open me">Hello</a>
</body>
</html>