Intrepid Posted December 5, 2014 Share Posted December 5, 2014 According to W3schools, it is helpful to use the height/width attribute because: "the browser does not know the size of the image, and cannot reserve the appropriate space to it." But, if i already scaled the image to the right pixel size that I want, shouldnt the browser then pre-load the image already in the correct size, which is by pixel size (since what other way should it load) This is what you want to do anyway because it takes up less bandwidth, So, if the image is already scaled to the right size, this then would render the height/width attribute redundant, or am I missing something here? thanks Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2014 Share Posted December 5, 2014 The width and height are used by the browser to reserve space for the image before the image has even started downloading. Link to comment Share on other sites More sharing options...
davej Posted December 5, 2014 Share Posted December 5, 2014 The difference is difficult to see unless you are on a low-bandwidth connection. When dimensions are given the webpage will be displayed with properly sized empty areas where the images will be loaded. When dimensions are not given the webpage is collapsed where the images are missing and will expand as the image are loaded and the sizes are determined. Link to comment Share on other sites More sharing options...
Intrepid Posted December 6, 2014 Author Share Posted December 6, 2014 The difference is difficult to see unless you are on a low-bandwidth connection. When dimensions are given the webpage will be displayed with properly sized empty areas where the images will be loaded. When dimensions are not given the webpage is collapsed where the images are missing and will expand as the image are loaded and the sizes are determined. Oh i see, so the dimensions are really not for the image itself, but for everything else in the webpage, so as to keep the structure of the page before it loads. And it is only the added bonus of the image being able to scale using this feature as well. This is what i was missing, and couldnt figure it out because my connection is not slow enough. thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now