{"id":9335,"date":"2022-10-06T04:58:41","date_gmt":"2022-10-06T04:58:41","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9335"},"modified":"2022-10-06T04:58:41","modified_gmt":"2022-10-06T04:58:41","slug":"html-alt-attribute","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/html-alt-attribute\/","title":{"rendered":"HTML alt Attribute"},"content":{"rendered":"\n<p>The HTML&nbsp;alt&nbsp;attribute is used in HTML and XHTML documents. It specifies an alternative text which must be rendered if the element cannot be displayed for some reason. The&nbsp;alt&nbsp;attribute can also be used by screen readers to allow visually impaired users to interact with a webpage. To be accessible, an image must have an&nbsp;alt&nbsp;attribute. However, it may not contain text (empty or null attribute).<\/p>\n\n\n\n<p>You can use the\u00a0alt\u00a0attribute on the following elements:\u00a0&lt;area>,\u00a0&lt;img>,\u00a0&lt;input>.<\/p>\n\n\n\n<p>It is required to use the&nbsp;alt&nbsp;attribute for the &lt;img&gt; element. For &lt;input&gt; elements, you can only use the&nbsp;alt&nbsp;attribute with &lt;input&nbsp;type=&#8221;image&#8221;&gt;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"syntax-4\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;img alt=\"alternative text\"&gt;\n&lt;area alt=\"alternative text\"&gt;<\/code><\/pre>\n\n\n\n<p>Use the&nbsp;title&nbsp;attribute to create a tooltip for an image.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-alt-span-attribute-used-on-the-lt-area-gt-element-7\">Example of the HTML&nbsp;alt&nbsp;attribute used on the &lt;area&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;p&gt;Click on the logo or on one of the logo item to watch it closer:&lt;\/p&gt;\n    &lt;img src=\"\/uploads\/media\/news_gallery\/0001\/01\/thumb_316_news_gallery_list.jpeg\"  width=\"250\" height=\"150\" alt=\"block\" usemap=\"#blockmap\"&gt;\n    &lt;map name=\"blockmap\"&gt;\n      &lt;area shape=\"circle\" coords=\"50,32,25\" alt=\"html\" href=\"\/uploads\/media\/book_gallery\/0001\/01\/d450f0358f947dffb3af91195c3002600d74101b.png\"&gt;\n      &lt;area shape=\"circle\" coords=\"218,115,25\" alt=\"css\" href=\"\/uploads\/media\/book_gallery\/0001\/01\/25521e981b34da57c8f51baddc5b76351b855818.png\"&gt;\n      &lt;area shape=\"circle\" coords=\"195,32,28\" alt=\"php\" href=\"\/uploads\/media\/book_gallery\/0001\/01\/4bbee6698c4884f25c46010d61b658dd62d2c04f.png\"&gt;\n      &lt;area class=\"homepage\" shape=\"rect\" coords=\"90,90,35,55\" alt=\"php\" href=\"https:\/\/www.w3docs.com\/\"&gt;\n    &lt;\/map&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-alt-span-attribute-used-on-the-lt-img-gt-element-9\">Example of the HTML&nbsp;alt&nbsp;attribute used on the &lt;img&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;img src=\"\/uploads\/media\/default\/0001\/01\/25acddb3da54207bc6beb5838f65f022feaa81d7.jpeg\" alt=\"Aleq\" width=\"200\" height=\"185\"\/&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-span-class-attribute-alt-span-attribute-used-on-the-lt-input-gt-element-11\">Example of the HTML&nbsp;alt&nbsp;attribute used on the &lt;input&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      input {\n        vertical-align: middle;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;form action=\"\/form\/submit\"&gt;\n      Email:\n      &lt;input type=\"email\" name=\"Email\"&gt;\n      &lt;input type=\"image\" src=\"https:\/\/i7.pngguru.com\/preview\/278\/823\/594\/computer-icons-button-clip-art-green-submit-button-png.jpg\" alt=\"Submit button\" width=\"60\" height=\"60\"&gt;\n    &lt;\/form&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The HTML&nbsp;alt&nbsp;attribute is used in HTML and XHTML documents. It specifies an alternative text which must be rendered if the element cannot be displayed for some reason. The&nbsp;alt&nbsp;attribute can also be used by screen readers to allow visually impaired users to interact with a webpage. To be accessible, an image must have an&nbsp;alt&nbsp;attribute. However, it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[327],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9335"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=9335"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9335\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}