In order to define the basic html elements, user have several types of attributes as listed below.
- Boolean Attribute
- Custom Attribute
- href Attribute
- Size Attribute
Boolean Attributes
The code below demonstrates the Boolean Attributes which do not require any value.
[html]
<!DOCTYPE HTML>
<html>
<body>
<audio controls loop>
<!-- Here controls and loop are boolean -->
<source src="horse.ogg" type="audio/ogg" />
<source src="horse.mp3" type="audio/mp3" />
</audio>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
http://www.splessons.com/wp-content/uploads/2016/05/horse.mp3
Custom Attribute
The code below demonstrates the custom attributes which is also called as data attributes.
[html]
<!DOCTYPE HTML>
<html>
<body>
<audio controls loop data-music="horse" >
<!-- data-music is custom attribute -->
<source src="horse.ogg" type="audio/ogg" />
<source src="horse.mp3" type="audio/mp3" />
</audio>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
http://www.splessons.com/wp-content/uploads/2016/05/horse.mp3
href Attribute
The code below demonstrates the
<a> tag , the linked address refers to the href attribute.
[html]
<!DOCTYPE html>
<html>
<body>
<a href="http://www.splessons.com/">This is a link</a>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
Size Attribute
The code below demonstrates the
<img> tag which contain
source attribute (src),
width and
height of the image.
[html]
<!DOCTYPE html>
<html>
<body>
<img src="splessons.jpg" width="104" height="142">
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.