Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Embedding Images | Working with Images and Visual Content
HTML Text and Media Foundations

bookEmbedding Images

To display images on your HTML page, you use the img element. This element requires a src attribute, which tells the browser the location of the image file you want to show. You can also add width and height attributes to control the size of the image directly in the HTML, making it easier to manage your page's layout and appearance.

index.html

index.html

copy

Specifying both width and height attributes on your images is important. By doing this, you help browsers reserve the right amount of space for each image before it loads. This improves the performance and stability of your page, preventing content from shifting around as images appear.

question mark

Why is it recommended to specify width and height attributes on img elements?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 1

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Suggested prompts:

Can you show me an example of how to use the img element with width and height?

Why is it important to prevent content from shifting as images load?

Are there any best practices for choosing image sizes in HTML?

Awesome!

Completion rate improved to 6.25

bookEmbedding Images

Pyyhkäise näyttääksesi valikon

To display images on your HTML page, you use the img element. This element requires a src attribute, which tells the browser the location of the image file you want to show. You can also add width and height attributes to control the size of the image directly in the HTML, making it easier to manage your page's layout and appearance.

index.html

index.html

copy

Specifying both width and height attributes on your images is important. By doing this, you help browsers reserve the right amount of space for each image before it loads. This improves the performance and stability of your page, preventing content from shifting around as images appear.

question mark

Why is it recommended to specify width and height attributes on img elements?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 1
some-alt