Get a Free Quote

We respect your privacy

Responsive Images – The Picture Element

6:54 am

Responsive Images – The Picture Element

  • Responsive web design (RWD) is an innovative solution to the big problem of having to design a different website for every other platform. The problem is even bigger now, with the number of different types of internet device on the constant rise. However, responsive web design is aimed at providing.
  • The website with knowledge to deal with almost all of the different devices like desktop computer, laptop, mobile phone, tablet , etc.
  • The way it works is that it adapts the layout to the viewing environment by using fluid, flexible images proportion based grids as well CSS3 media quires to make sure the website appears just right.
  • The flexible images used make sure that they do now show outside of their containing element.

The growing demand:

Screenshot from 2014-07-28 13:25:39

  • A visit to a web development company close by all that you need to understand the true demand for websites that work on all platforms.
  • The fact of the matter is that now a days almost every other client demands a mobile version of their website, since not everyone is aware of the responsive design methodologies.
  • Once it is explained to them that one mobile website will not cover all the different platforms like iPhone, iPad, Blackberry, netbook and the several Android devices they tend to hesitate on their demand for a mobile website.
  • Thus when given the option of making their website responsive to solve their problems they don’t think twice about opting for the responsive design. With the demand of the responsive design so high, it is something you cannot ignore.
  • A very popular website developed using the responsive web design concept is Food Sense (foodsense.is). This is a very good example of a responsive web design concept.
  • The website is practical and maintains all the proportions and design elements no matter which platform you view it on. Since this website is to do with many different recipes to cook up the perfect dish, the changes of it being used on multiple platforms are extremely high too.

Using ‘picture element’ for responsive images:

  • There are several elements of HTML that you may not yet be familiar with. The element ‘<video>’ of HTML5 has grown quite popular and is used extensively to display videos.
  • The element ‘<picture>’ is pretty much similar, in the sense that it too allows the use of alternative source files for a single image.
  • There are several benefits of doing things this way. Just at the top of my head I can think of a couple of reasons. One being that this will reduce the bandwidth usage, since instead of having to scaling the images for the users on different displays, you can simply provide them with the source of the image that is perfect for them.
  • The ‘<picture>’ element can contain multiple ‘<source>’ elements and even consist of fallback markup rendered by browsers that do not support it. The media attribute on each of the ‘<source>’ element accepts the same media query as the layout CSS and ‘srcset’ accepts a list of one or more sources. Here is a quick example:

<picture> <source media=”(min-width:550px)” srcset=”large.png”> <source srcset=”small.png”> <img src=”fallback.png” alt=”..”> </picture>

  • The way the above displayed code works is that the larger of the two sources is served to viewports larger that 550px width, and the smaller source to smaller view ports.
  • It is important to note that the order is important since the ‘<picture>’ element uses the first source element that matches the current context.
  • The ‘<picture>’ element differs from ‘<img>’ element in the sense that the ‘<picture>’ element and its ‘<source>’ element will not render anything by themselves unlike the ‘<img>’ element.
  • The ‘<picture>’ element is more of a wrapper and controller for the ‘<img>’ element and passes the most appropriate source for the ‘<img>’ tag to render.

Things to keep in mind are:

  • The ‘<img>’ tag is going the real rendering work.
  • The ‘<picture>’ tag should never be used to render drastically different images.
  • A single ‘alt’ should be used to accurately describe the subject of the image no matter which source is selected.

But that’s not all. We have our layouts covered for different dimensions so far, but what about the battle of high resolutions screens. With the ‘<picture>’ element you have that covered as well. The syntax for ‘<img>’ in cases where you need to deal with resolution switching is:

<img src=”sd.png” srcset=”hd.jpg 2x”>

Thus the full thing will look something like this:

<picture> <source media=”(min-width:550px)” srcset=”large.png, large-hd.png 2x”>

<source srcset=”small.png, small-hd.png 2x”> <img src=”fallback.png” alt=”..”>

</picture>

Conclusion:

This new markup is yet to be implemented in any stable browser, although it is definitely the right time to take note of the extended capabilities of this markup for use in the immediate future.

Alakmalak is one web development firm that keeps up with the changes in technology, especially the changes and advancements that affect the world of web development. Thus it should come as surprise that Alakmalak has grown in size ever since it started way back in 2000 and it is still growing. They carry with them all that experience into the development of every single project and have thus Developed more than 2000 projects now for clients from all around the world. This is a feat that not many companies can boast about.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...Loading...

Comments are closed.