Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Attributes

0/1

HTML Paragraphs

0/1

HTML Formatting

0/1

HTML Comments

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML Symbols

0/1
Text lesson

Responsive Images

Responsive images are images that adjust smoothly to accommodate any browser size.

Using the width Property

When the CSS width property is configured to 100%, the image becomes responsive, allowing it to resize proportionally to both larger and smaller dimensions.

IMG_3853

Example

<img src=”img_girl.jpg” style=”width:100%;”>

Observe that in the aforementioned example, the image can be enlarged beyond its original dimensions. In many scenarios, a preferable approach would be to utilize the max-width property instead.

Using the max-width Property

When the max-width property is defined as 100%, the image will shrink if necessary, but it won’t enlarge beyond its original dimensions.

IMG_3854

Example

<img src=”img_girl.jpg” style=”max-width:100%;height:auto;”>

Show Different Images Depending on Browser Width

The HTML <picture> element enables you to specify varying images for different browser window sizes.

Adjust the browser window size to observe how the image below adapts based on the width.

IMG_3856

Example

<picture>
  <source srcset=”img_smallflower.jpg” media=”(max-width: 600px)”>
  <source srcset=”img_flowers.jpg” media=”(max-width: 1500px)”>
  <source srcset=”flowers.jpg”>
  <img src=”img_smallflower.jpg” alt=”Flowers”>
</picture>