Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Add Images to an HTML document

    Taylor BellTaylor Bell
    htmlHTML 5

    Images make a great addition to a web page. In this lesson, we will use the <img> tag to add an image to our page.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: Let's add an image, so we'll do an img. This is going to be the first time that we use an attribute. We're going to use the source attribute, src. Then we'll do an equals sign and two quotes. Within our quotes we're going to be giving the address of the image. I'm pasting in the address of a picture of a burrito.

    Let's add a second-level heading that says "burrito." Below the image, I'm going to add a paragraph giving credit for this burrito picture. Another important attribute of images is the alt attribute. This is text that's used to describe the image in case it can't load. If the image can't load, there's nothing there to indicate that there should be a picture there.

    The alt tab will let me write "basic burrito." We can now see that we have a broken image where our burrito should be. Putting our address back, our burrito is back as well.