HTML Attributes(2)
The width and height Attributes
The <img> tag should also contain the width and height attributes, which specify the width and height of the image (in pixels):
Example
<!DOCTYPE html>
<html>
<head>
<title>
Dog
</title>
</head>
<body>
<img src="images/dog.jfif"
height ="200" width="200">
<h3>woof woof!</h3>
</body>
</html>
This is how a new webpage opens and images are displayed.
The alt Attribute
The required alt attribute for the <img> tag specifies an alternate text for an image, if the image for some reason cannot be displayed. This can be due to a slow connection, or an error in the src attribute, or if the user uses a screen reader.
Example
<!DOCTYPE html>
<html>
<head>
<title>
Dog
</title>
</head>
<body>
<p>The alt attribute should reflect the image content,
so users who cannot see the image get an
understanding of what the image contains:</p>
<img src="images/cutedog.gif"
alt="cute dog" width="200">
</body>
</html>
The style Attribute
The style attribute is used to add styles to an element, such as color, font, size, and more.
Example
<!DOCTYPE html>
<html>
<body>
<h2>The style Attribute</h2>
<p>The style attribute is used to add styles to an element, such as color:</p>
<p style="color:red;">This is a red paragraph.</p>
</body>
</html>
No comments:
Post a Comment