How to write different HTML for different screen sizes

Alon picture Alon · Nov 28, 2011 · Viewed 31.2k times · Source

I understood how I change CSS via media queries (such as media="screen and (max-width:640px)")

but let's say I want to write (just for example)

<div>
[if screen resolution is lower then 960 px]
    <div>
    some new text only for lower resolution
    </div>
[end of condition]
</div>

What is the condition I need to write to get it right?

Answer

Jan Dragsbaek picture Jan Dragsbaek · Nov 28, 2011

As far as i have experienced, you cannot do media queries inside HTML pages. You need to do it from within your CSS.

But if you want to show some special text only when it is below a certain resolution, why not only make it visible when the resolution is lower than 960px?

Creating responsive designs is very different from a regular design, because you have to think a lot more (which is haaard)