Free Ebook cover Complete HTML, CSS and Javascript course to become a Front End Developer

Complete HTML, CSS and Javascript course to become a Front End Developer

3.79

(14)

125 pages

Introduction to HTML: basic structure, tags and attributes: Image tags (img)

Capítulo 12

Estimated reading time: 4 minutes

+ Exercise
Audio Icon

Listen in audio

0:00 / 0:00
4.8 Introduction to HTML: Basic structure, tags and attributes

Introduction to HTML: Basic structure, tags and attributes: Image tags (img)

HTML, or Hyper Text Markup Language, is the standard markup language for creating web pages. The basic structure of an HTML document consists of tags, which are used to define elements, and attributes, which are used to specify the characteristics of those elements.

HTML tags are the foundation of any web page. They are used to create and organize page content, including text, images, links, lists, tables, and more. Each tag is represented by a set of characters surrounded by angle brackets (< and >). For example, the <h1> is used to define a level 1 title, the <p> is used to define a paragraph and the <img> is used to insert an image.

The image tag <img> is one of the most important tags in HTML. It allows you to insert images into your web page, making it more attractive and informative. The <img> is an empty tag, which means it does not have a closing tag. Instead, it uses attributes to specify the image to display and other characteristics of the image.

How to use the <img> image tag

To insert an image on your web page, you need to use the <img> with the 'src' attribute. The 'src' attribute specifies the URL of the image you want to display. For example:

<img src="imagem.jpg">

In this example, the image 'imagem.jpg' will be displayed on the web page. The image must be in the same directory as the HTML file, or you must specify the full path to the image.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

Image tag attributes <img>

In addition to the 'src' attribute, the <img> also supports several other attributes. The most common are 'alt', 'width' and 'height'.

The 'alt' attribute is used to specify alternative text for the image, which will be displayed if the image cannot be loaded. This is an important attribute for accessibility as it allows screen reader users to understand the content of the image. For example:

<img src="imagem.jpg" alt="Image description">

In this example, if the image cannot be loaded, the text 'Image description' will be displayed instead.

The 'width' and 'height' attributes are used to specify the width and height of the image, respectively. They are specified in pixels. For example:

<img src="imagem.jpg" alt="Image description" width="500" height="300">

In this example, the image will be displayed with a width of 500 pixels and a height of 300 pixels.

In short, the image tag <img> It is an essential part of any web page. It allows you to insert images into your page, making it more attractive and informative. When using the <img> tag, it is important to remember to use the 'alt' attribute to improve accessibility and the 'width' and 'height' attributes to control the image size.

Now answer the exercise about the content:

What does the <img> in HTML allows you to do?

You are right! Congratulations, now go to the next page

You missed! Try again.

The tag in HTML is specifically used to insert an image into a web page. It utilizes attributes such as 'src' to specify the image source, making the page more visually appealing and informative. Therefore, the correct option is Option 2.

Next chapter

Introduction to HTML: basic structure, tags and attributes: Lists in HTML

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.