HTML alt Attribute
The alt attribute in HTML provides alternative text for an image if the image cannot be displayed. It improves accessibility and provides context for screen readers.
Example: This example explains the HTML alt Attributes to specify the name of the file when the image is not loaded properly.
<html>
<head>
<title>alt Attribute</title>
</head>
<body>
<!--If the image is not found or the img field
is left blank the alt value gets displayed-->
<img src=
"https://media.w3wiki.org/wp-content/cdn-uploads/Geek_logi_-low_res.png"
alt="The Logo"><br>
<img src=""
alt="Since the src value is blank,the alt value is displayed">
</body>
</html>
Output:
HTML Attributes
HTML attributes provide additional information about elements within an HTML document. Every HTML element can have attributes. Attributes are always defined in the start tag. They are specified using a name/value pair format, where the attribute name defines the property, and its value provides specific details, like name=”value”. These attributes impact content display and interaction on web pages.
Let’s explore the key aspects of HTML attributes:
Table of Content
- HTML Global Attributes
- HTML src Attribute
- HTML alt Attribute
- HTML width and height Attribute
- HTML id Attribute
- HTML title Attribute
- HTML href Attribute
- HTML style Attribute
- HTML lang attribute
Contact Us