March 25, 201313 yr This a simple one really. All the stuff I do is responsive and despite the issues involved, I don't usually have problems with images other than the occasional 'serve scaled images' to improve the speed. The little gripe I have at the moment is when I do testing on numerous platforms, I continually have recommendations to set height and width attributes within the markup. I have done this, but it doesn't have much of an effect. The sites load up relatively well and the images resize accordingly, but the perfectionist in me wants to ensure everything is running smoothly and effectively (I made another post along the same lines about validation a minute ago). A bog standard HTML example would be: <img src="img/some-image.png" alt="Some image" height="400" width="400"/> and the CSS: img { max-width: 100%; height: auto; } Granted each image is different and this is only a basic example. A lot of the sites I've worked on in the past don't have the height and width attributes set in the markup or css. Should I get out my hammer now?
March 27, 201313 yr I haven't set them in html since my dreamweaver days (as it was automatic). I never really thought about it since it passes validation without. There are a lot of attributes that can be set but aren't obligatory. From where did you get the recommendations?
March 28, 201313 yr The reason it's recommended to set the dimensions (or one, at least) is because if the image isn't loadable for any reason, the layout still keeps it's spacing. This happens when you have your height set to auto in css too. View here for an example. In the example, the paragraph is supposed to be 200px down. Play about with it to see what takes effect. Hope I understood the question ~evu.
Create an account or sign in to comment