We have seen few HTML tags and their usage and we used them so far in their simplest form, but most of the HTML tags can also have attributes, which are extra bits of information.
All HTML elements can have attributes.
<a href="https://parrot-tutorial.com/">Parrot Tutorial</a>
You will learn more about links later in this tutorial.
<img src="parrot-icon.png" alt="Parrot Image">
You will learn more about images later in this tutorial.
alt attribute specifies an alternative text to be used, when an image cannot be displayed.
The easiest way to test your
alt text is to purposely misspell your image name.
<img src="/images/carrrrr.jpg" alt="Car image">
style attribute Specifies an inline CSS style for an element.
<p style="color:red;">This text is RED</p>
<h1 style="background-color:yellow;">Hello World!</h1>
You can learn more about CSS in our CSS tutorial.
The language of the document can be declared in the
The language is declared with the
Declaring a language is important for screen readers and search engines.
"en" represents english.
For complete language code reference click here
title attribute is added to an element. The value of the title attribute will be displayed as a tooltip when you mouse over the content of the element.
<p title="I am tooltip">Hover over me</p>
Double quotes around attribute values are the most common in HTML, but single quotes can also be used.
In some rare situations, when the attribute value itself contains quotes, it is necessary to wrap attribute value inside single quotes:
<p title='Hello "NTR" Junior'>
Or vice versa:
<p title="Hello 'NTR' Junior">
Below is an alphabetical list of some attributes often used in HTML:
|alt||Specifies an alternative text in case an image can't be displayed|
|class||Specifies a class name for an element|
|href||Specifies the URL (Location) of a linked resource|
|height||Specifies the height of the element|
|id||Specifies a unique id for an element|
|lang||Specifies the language of a document|
|src||Specifies the URL of the embeddable content|
|style||Specifies an inline CSS style for an element|
|title||Specifies extra information about an element (Text to be displayed in a tooltip when hovering over the element)|
|width||Specifies the width of the element|
A complete list of all attributes for each HTML element, is listed in our: HTML Attribute Reference.