HTML

HTML Attributes || Bcis Notes

HTML Attributes

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:

CODE

RESULT:

2.The src Attribute:-

HTML images are defined with the <img> tag. The filename of the image source is specified in the src attribute.

CODE:

RESULT:

 

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.

CODE:

RESULT:

 

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):

CODE:

RESULT:

 

5.The style Attribute:
The style attribute is used to specify the styling of an element, like color, font, size, etc.

CODE:

RESULT:

 

 

 

 

 

 

 

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

CODE:

 

RESULT:

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:

CODE:

RESULT:

 

 

 

 

 

 

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:

GOOD:

 

BAD:

 

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.

CODE:

RESULT:

HTML Attributes:
Below is an alphabetical list of some attributes often used in HTML, which you will learn more about in this tutorial:

You may also like:HTML Elements

Leave a Reply

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