Basics of web development

HTML Images

Easy
15 min

The HTML image tag is used to add images to an HTML page. Adding an image is done with the <img> tag (image tag), which contains several different attributes. Here is an example of using the image tag:

<img src="kissa.jpg" width="613" height="640" alt="Caption">

"src" (source) attribute determines the image URL. This attribute is required because the browser doesn't know where to find the image without it.

"alt" (alternative) attribute specifies alternative text to be displayed if the image cannot be loaded correctly or if the user is using a text-only browser. This attribute is also important as it helps visually impaired users understand the content of the image.

"width" and "height" attributes define the width and height of the image in pixels. These attributes are optional, but it is recommended to use them because they help the page load faster when the browser knows how much space is reserved for the image.

Practice

Kokeile itse!

Valitettavasti Replit-palvelu on muuttnut lennosta eikä enää anna suorittaa näitä koodeja suoraan selaimessa. Voit klikata alla olevaa "Open in Replit" linkkiä ja avata koodin Replit-palvelussa. Meillä on työn alla etsiä Replitille korvaaja.

hakatemia pro

Ready to become an ethical hacker?
Start today.

As a member of Hakatemia you get unlimited access to Hakatemia modules, exercises and tools, and you get access to the Hakatemia Discord channel where you can ask for help from both instructors and other Hakatemia members.