How to give static?

Please tell me how to properly(professionally) to load a static page? I often see that instead of img tag use a div with a background which is a picture ie load it through css, not html tag. How to do it correctly and why?
July 9th 19 at 11:23
3 answers
July 9th 19 at 11:25
The example that you gave, does not apply to the concept of "right to podrozhat statics." To download the static file, there are some common rules that substantially ease this download.
Here they are:
  • Merging JS and CSS files in 1 - reducing the number of requests to the server
  • Combine multiple images into a sprite again reducing the number of queries
  • Convert images to Base64 - again reducing the number of queries, since the picture now is in the body CSS file
  • Using caching
  • Use a separate server for download static - reduces the load on the primary server, overcomes the rules of the browsers in the number of possible parallel downloads
  • Using Gzip on the server to minimize the weight of the statics

Yes, and much more.

As you say, it's more the rules of layout, the essence of the concept is to separate design from content. But this is not an iron concept, can be many exceptions. For example take a picture of the product in the catalogue. Normally, this is a picture - IMG as it is content. But if suddenly this very picture need something interesting to draw and add some effects or alignment, then regular IMG here already alas is not suitable and easier to use it as the background to a DIV-y. Well, etc.
July 9th 19 at 11:27
I make div with background-image when the picture is needed only for decoration.
if the picture is part of the content, the img
July 9th 19 at 11:29
When you want to control the behavior of the object through JS, or image is part of the content - img, otherwise the background div

Find more questions by tags CSSHTML