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:
alt: Provides alternative text if the image doesn’t load .widthandheight: 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
EasyAdd the following attributes to the image:
alt: "A beautiful bird"width: "400"height: "250"
Cheat sheet
Use additional attributes to improve your images:
alt: Provides alternative text if the image doesn't loadwidthandheight: Control the size of the image in pixels
<img src="img.jpg" alt="A scenic view of mountains" width="600" height="400" />Always include alt for accessibility and use dimensions to maintain design consistency.
Try it yourself
<!DOCTYPE html>
<html>
<body>
<img src="https://4.img-dpreview.com/files/p/E~TS590x0~articles/3925134721/0266554465.jpeg">
</body>
</html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
2Text and Formatting
HeadingsParagraphsLine BreaksBold and Italic TextBold and Italic AgainRecap - Formatting8Forms and Inputs Part 1
Form BasicsText InputsInput AttributesPassword FieldLabels for InputsRecap - Basic Form11Event Registration Page
Project OverviewHeader Section9Forms and Inputs Part 2
Radio ButtonsCheckboxesDropdownsButtonsButtons in FormsRecap - Forms #1Recap - Forms #2