
HTML Attributes
Attributes in HTML are used to put some additional data about elements in HTML, these usually come in name/value pairs like name=” value”; and specified in the start Tag.
There are some basic standard attributes to follow: class,contenteditable, title, style,data,dir,hidden,contextmenu,id,lang ,etc…
Let us start with some of it.
The href Attribute
HTML links are defined with the <a> tag. The address to that hyper refrence attribute is:
<a href=”https://www.codingtag.com“>Code Experts</a>

The src Attribute
Images in HTML are defined by <img> tag
The filename of the source is specified in the src attribute:
<img src=”CodingTag.jpeg”>
The width and height Attributes
HTML images also have width and height attributes, which deals the width and height of the images:
<img src=”codingtag.png” width=”500″ height=”500″>
The alt Attribute
This attribute is an alternative of any image , whenever an image is lost of could not be loaded, then the text in the tag showed up. 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.
<img src=”img_girl.jpg” alt=”Girl with a jacket”>
The style Attribute
The style attribute is used for the styling of an element, like color, font, size, etc.
<p style=”color:red”>This is a red paragraph.</p>
The lang Attribute
The language of the document can be declared in the <html> tag. which is declared with the lang attribute. It is for all the applications and search engines and websites .
<!DOCTYPE html>
<html lang=”en-US”>
<body>
…
</body>
</html>
The title Attribute
Here , a title attribute is placed in the <p> tag element. and the value of that title attribute will be displayed as a tool tip when we hover the mouse on the paragraph:
<p title=” I’m a tooltip”>
This is a paragraph.
</p>
List of Attributes
| Attribute | Description |
| alt | Specifies an alternative text for an image, when the image cannot showed up |
| disabled | Specifies that an input element should be disabled |
| href | Specifies the source URL (web address) for a link |
| id | Specifies a unique id for an element |
| src | Specifies the source URL (web address) for an image |
| style | Specifies an inline CSS style for an element |
| title | Specifies extra information about an element (displayed as a tooltip) |
Abstract of this Chapter:
- All HTML elements can have attributes
- The title attribute provides additional “tool-tip” information
- The href attribute provides address information for links
- The width and height attributes provide size information for images
- The alt attribute provides the text for screen readers
You can easily prepare for HTML Attribute by implementing all examples.
Learn HTML INTERVIEW ONLINE WITH DOWNLOAD PDF : https://www.codingtag.com/html-interview-questions
