Menu
Coddy logo textTech

Image Attributes

Part of the Fundamentals section of Coddy's HTML journey. Lesson 24 of 60.

Let’s explore some additional attributes to improve your images:

  1. alt: Provides alternative text if the image doesn’t load .
  2. width and height: Control the size of the image in pixels.

Here’s an example:

<img src="img.jpg" alt="A scenic view of mountains" width="600" height="400" />

This sets the image source, provides a description, and sizes it to 600x400 pixels. Always include alt for accessibility and use dimensions to maintain design consistency. 

challenge icon

Challenge

Easy

Add the following attributes to the image:

  1. alt: "A beautiful bird"
  2. width: "400"
  3. height: "250"

Try it yourself

<!DOCTYPE html>
<html>
    <body>
         <img src="https://upload.wikimedia.org/wikipedia/commons/e/ee/Baya_Weaver_in_Bhigwan_August_2025_by_Tisha_Mukherjee_04.jpg?utm_source=commons.wikimedia.org&utm_campaign=index&utm_content=original">
    </body>
</html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Web playground