Menu
CoddyTech

Images

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

Images can make your webpage more engaging, and adding them in HTML is simple using the <img> tag. The <img> tag is self-closing, meaning it doesn't need an ending tag.

To display an image, you need to use the src attribute. This attribute specifies the image's location (URL or file path). Here's an example:

<img src="https://coddy.tech/images/bit.svg" />

In this example, the browser will load and display the image from the URL https://coddy.tech/images/bit.svg.

Self-closing tags, like <img>, are used for elements that have no content inside, so they have no closing tag. In HTML5 the slash at the end is optional: <img src="bit.svg"> and <img src="bit.svg" /> are both valid. This course writes />.

challenge icon

Challenge

Easy

Add an image to HTML document, you can use the URL from the example in the lesson or any other URL.

Make sure you see an image!

Try it yourself

<!DOCTYPE html>
<html>
    <body>
        <!-- Write code here -->
    </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