HTML - attributes - alt

revision:


Content

"alt" attribute : provides alternative information for an image syntax some examples


"alt" attribute : provides alternative information for an image

top

It provides a text, if a user for some reason cannot view an image (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

It can be used on the following elements:<area >, <img>, <input>. The alt attribute is required for the <img> element. For <input> elements, the alt attribute can only be used with <input type="image">. To create a tooltip for an image, use the title attribute!


syntax

top

<img alt="alternative text">

<area alt="alternative text">

<input alt="alternative text">

alternative text specifies an alternate text for the image.


some examples

top
holiday
codes:
                    <img src="../../pics/1.jpg" alt="holiday" width="300" height="300">
                

Click on the image, and the input will be sent to a page on the server called "/action_page.php".

codes:

                    <p class="spec">Click on the image, and the input will be sent to 
                    a page on the server called "/action_page.php".</p>
                    <form style="margin-left: 5vw;" action="/action_page.php">
                        <label for="fname">First name:</label>
                        <input type="text" id="fname" name="fname">
                        <input type="image" src="../../pics/submit.gif" alt="Submit" width="24" height="24">