Skip to main content
Added notes for HTML5
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

The width and height attributes of the img element are not required under any DOCTYPE, if that is what were implying. There is no difference between Strict and, Transitional and HTML5 in this respect.

As you suggest, these attributes were only 'required' to reserve the space on the page and prevent the page moving around as it loads - which is important. This can be achieved using CSS instead providing the CSS loads quickly enough - it is likely to load before the images anyway, so all should be good.

It is also possible (and valid) to specify just one attribute, width or height and the browser will calculate the omitted value in order to maintain the correct aspect ratio.

You can specify percent values in the attributes if required. You don't need to use CSS for this, if that is what you are implying. EDIT: However, I believe this has changed slightly under HTML5. Under HTML5 the width and height can only take a pixel value, in other words a valid non-negative integer.

Whether you use the width and height attributes can depend on your design. If you have lots of differently sized images, do you want to lump all the dimensions in the CSS or include them with the img?

The width and height attributes of the img element are not required under any DOCTYPE, if that is what were implying. There is no difference between Strict and Transitional in this respect.

As you suggest, these attributes were only 'required' to reserve the space on the page and prevent the page moving around as it loads - which is important. This can be achieved using CSS instead providing the CSS loads quickly enough - it is likely to load before the images anyway, so all should be good.

You can specify percent values in the attributes if required. You don't need to use CSS for this, if that is what you are implying.

Whether you use the width and height attributes can depend on your design. If you have lots of differently sized images, do you want to lump all the dimensions in the CSS or include them with the img?

The width and height attributes of the img element are not required under any DOCTYPE, if that is what were implying. There is no difference between Strict, Transitional and HTML5 in this respect.

As you suggest, these attributes were only 'required' to reserve the space on the page and prevent the page moving around as it loads - which is important. This can be achieved using CSS instead providing the CSS loads quickly enough - it is likely to load before the images anyway, so all should be good.

It is also possible (and valid) to specify just one attribute, width or height and the browser will calculate the omitted value in order to maintain the correct aspect ratio.

You can specify percent values in the attributes if required. You don't need to use CSS for this, if that is what you are implying. EDIT: However, I believe this has changed slightly under HTML5. Under HTML5 the width and height can only take a pixel value, in other words a valid non-negative integer.

Whether you use the width and height attributes can depend on your design. If you have lots of differently sized images, do you want to lump all the dimensions in the CSS or include them with the img?

Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

The width and height attributes of the img element are not required under any DOCTYPE, if that is what were implying. There is no difference between Strict and Transitional in this respect.

As you suggest, these attributes were only 'required' to reserve the space on the page and prevent the page moving around as it loads - which is important. This can be achieved using CSS instead providing the CSS loads quickly enough - it is likely to load before the images anyway, so all should be good.

You can specify percent values in the attributes if required. You don't need to use CSS for this, if that is what you are implying.

Whether you use the width and height attributes can depend on your design. If you have lots of differently sized images, do you want to lump all the dimensions in the CSS or include them with the img?