css - Is it still relevant to specify width and heigth attribute on images in HTML? -


i found a similar question here, answer: "you should define width , height in image tag." 2009.

in meantime, many things has changed on frontend. doing responsive page design now, many devices , sizes simultaneously (mobile, tablet, desktop...).

so, wonder still necessary specify width , height attributes in 2016, , reason (for responsive, page speed, seo...)?

an img element has width , height attributes, they're not required under doctype.

width , height attributes 'required' or relevant reserve space on page , prevent page moving around loads - important. can achieved using css instead providing css loads enough - load before images anyway, should good.

it possible (and valid) specify 1 attribute, width or height , browser calculate omitted value in order maintain correct aspect ratio.

you can specify percent values in attributes if required. don't need use css this, if implying.

also, relevant add - under html5 width , height can take pixel value, in other words valid non-negative integer.

whether use width , height attributes can depend on design. if have lots of differently sized images, want lump dimensions in css or include them img?


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -