Narayan Vaidyanathan

  • Wanna feel my punch?

    Check out my creative and interesting projects.

    I specialize in creating usable designs for the web with a professional approach and convert them into HTML 4 & 5 / CSS with Open Source Themes

Responsive website media query syntax

Dear UI developers, This is for another responsive media query syntax order. If you’ve yet to get your hands dirty with media queries, now is your chance to create your first responsive website design.


The first step to creating our responsive layouts is to plan out what resolutions we’re going to cater for. Common resolutions include the 320px portrait width of smartphones, 768px portrait width of tablets, 1024px landscape width of tablets (and typical netbook resolutions) as well as various desktop monitor resolutions. It’s worth mentioning that a layout that only caters for preset resolutions is often referred to as being ‘adaptive’, whereas a truly ‘responsive’ layout will be built using ems or percentages, allowing an infinite level of scaling.

I’m adding the media queries and additional declarations to a separate CSS file, but they could be added to your main stylesheet.


<meta name=”viewport” content=”width=device-width; initial-scale=1.0″>


The width of the original layout is 960px, so any resolution below this value will generate horizontal scrollbars and cut-off the content. Therefore the first of our media queries will target screens with a width of less than 960px;.

@media screen and (max-width: 960px) {


The next most popular resolution under 960px width is 768px to cater for portrait tablet screens. This Typo design is built using a grid, so to stay true to the layout we can simply remove a column to leave a width of 758px. The original layout can then be narrowed down to fit by reducing the margin on the content div as well as reducing the overall width of the sidebar.

@media screen and (max-width: 758px) {


The value of 758px can then be used for the next media query, so anything smaller than this size will trigger the next layout. At this point the sidebar is too narrow to be made any smaller, so instead it can be naturally flowed underneath the main content when the grid is narrowed by a few more columns. This means the actual sidebar div’s width can be increased to fill the width of the new layout and its child elements floated to fill out the extra horizontal space.

Other areas such as the header have become too narrow to hold the logo and navigation side by side, so the navigation elements are altered to span the width of the layout on a new line.

@media screen and (max-width: 524px) {


The third and final media query in our responsive layout will cater for extremely small resolutions such as smartphones. This particular layout is narrower than the original content width, so this div also needs altering with a new declaration in the media queries CSS file. The extremely narrow view has dropped each of the post-info links on a new line, but decreasing the margin between them helps repair some of the floats.

This is basic, you have to write syntax more than this three 3 media query syntax in real time. for testing purpose you can test with following options

From server means:

from local hard disk:

using firefox you can test with developer add-on tools menu >> web developer  >> responsive design view(with shortcut of  Ctrl + Shift+M for windows) Lot of responsive patterns available in following path, you can use it in your real time…


Thanks for reading this article.

  • Designed and Developed by Narayan
  • Like Narayan ?
    Connect with me