FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

Media Queries Responsive Website Layout Tutorial

Published :
Author :
Adam Khoury
Learn to easily create responsive website layouts using CSS media queries. Media queries allow us to target a particular media type and then apply zero or more expressions that check for the conditions of particular media features. Using this logic we can adjust all CSS for our site according to the screen size of the device that a user is viewing it with. Example 1 - Media Queries Changing Stylesheet <!DOCTYPE html> <html> <head> <link rel="stylesheet" media="screen and (min-width: 0px)" href="small.css"> <link rel="stylesheet" media="screen and (min-width: 1000px)" href="medium.css"> <link rel="stylesheet" media="screen and (min-width: 1400px)" href="large.css"> </head> <body> <div id="mydiv">example element</div> </body> </html> Example 2 - Media Queries Inline CSS <!DOCTYPE html> <html> <head> <style> @media screen and (min-width: 0px) { div#mydiv{ width:500px; margin:0px auto; height:100px; background: #D5E600; font-size:27px; } } @media screen and (min-width: 1000px) { div#mydiv{ width:900px; margin:0px auto; height:100px; background: #D5E600; font-size:27px; } } </style> </head> <body> <div id="mydiv">example element</div> </body> </html>