Is setting the image size with CSS “good” like setting them in HTML?

When I first studied HTML a very long time ago, I was told that it is important to always set the size of your images in your HTML so that browsers can draw an empty box where the image, page should go, and then load and display the images where they belong. If you didn’t set the width and height for your images, the browser would have to download the images first to find their sizes, and this would slow down the page loading for people with crappy connections.

Over the past few years I have been using CSS, I always add ads widthand heighttags imgin your HTML. My question is: does it set the width and height in the stylesheet and not add these HTML attributes as well? This certainly makes my Spartan HTML cleaner without them.

+5
source share
7 answers

This is a good question, but it is a bit subjective and can lead to more discussion than is usually recommended for SO.

In the 90s, browsers were slow, and the Internet too. 56k took some time to transfer medium-sized images. During this time, the layout would be resized to fit the image.

, , . , . , , , .

CSS , CSS , .

, ( ) trump CSS . , , , .

CSS, .

+1

, , CSS.

, CSS . , CSS , , , .

, , CSS.

+5

, CSS .

, - . , , , , , , .

, .

+1

:

/ CSS?

inline. img, , .

, , img, CSS . , , alt. , , CSS .

:

, CSS.

, inline ( CSS ).

+1
0

CSS , - , .

div CSS, background-image:

0

HTML- - - 14.4K, HTML.

. , , CSS HTML-, , , ​​ , CSS, , , .

, HTML , - , .

-, HTML . , , . , , , .

, , , , .

, , .

0

All Articles