- Introduction of HTML || Bcis Notes
- HTML Editor || Bcis Notes
- HTML Basic Tag || Bcis Notes
- HTML Elements || Bcis Notes
- HTML Attributes || Bcis Notes
- HTML Headings And Paragraphs || Bcis Notes
- HTML Styles and Formatting || Bcis Notes
- HTML Comments and Colors || Bcis Notes
- HTML Quotations || Bcis Notes
HTML Attributes || Bcis Notes
All HTML elements can have attributes. Attributes provide additional information about an element. Attributes are always specified in the start tag. Attributes usually come in name/value pairs like name=”value”.
1. The href Attribute:
HTML links are defined with the <a> tag. The link address is specified in the href attribute:
2.The src Attribute:-
HTML images are defined with the <img> tag. The filename of the image source is specified in the src attribute.
3.The width and height attributes:
HTML images also have width and height attributes, which specifies the width and height of the image: As we insert image and define height and width like above img source attributes.
4.The alt Attribute:
The alt attribute specifies an alternative text to be used if an image cannot be displayed.
The value of the alt attribute can be read by screen readers. This way, someone “listening” to the webpage, e.g. a vision-impaired person, can “hear” the element. The alt attribute is also useful if the image cannot be displayed (e.g. if it does not exist):
5.The style Attribute:
The style attribute is used to specify the styling of an element, like color, font, size, etc.
6.HTML lang Attribute:
This attribute is used to specify the language of the element content. Some examples of languages are en for English, es for Spanish, etc
7.The title Attribute
Here, a title attribute is added to the <p> element. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph:
8. We Suggest: Quote Attribute Values:
The HTML standard does not require quotes around attribute values. The href attribute, demonstrated above, can be written without quotes:
9.Single or Double Quotes?
Double quotes around attribute values are the most common in HTML, but single quotes can also be used. In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes: Here is the example using both quotes.
Below is an alphabetical list of some attributes often used in HTML, which you will learn more about in this tutorial:
If you liked our content HTML Attributes, then please don’t forget to check our other content HTML Headings And Paragraphs.