6.10 img Element

Now that you know about image file formats, it’s time to focus on the nuts and bolts of how to display an image on a web page. In Chapter 4, we introduced the img element, which displays images. In this section, we’ll review what you learned and provide more details.

Let’s jump right into an img element example:

<img src="../images/winkingSmiley.gif"  alt="Winking Smiley Face" width="50" height="50">

The src attribute specifies the image’s filename and the location of the image’s file. In this img element, the filename is winkingSmiley.gif. The location is indicated by the path that comes before the filename. The path that comes before winkingSmiley.gif is ../images/. Do you remember what the .. is for? The .. says to move ...

Get Web Programming with HTML5, CSS, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.