Divide CSS in blocks to operate according to screen size (width and height)
@media screen and (max-width: 768px) {
/* Code for screens with up to 768px of width */
}
Prioritize properties
* {
background-color: white;
}
@media screen and (max-width: 768px) {
background-color: red; /* Won't be applied */
background-color: blue !important;
}
Separate mobile and desktop CSS sources.
<link rel="stylesheet" src="style.css">
<link rel="stylesheet" src="mobile.css" media="screen and (max-width: 768px)">
To follow a mobile first approach, it is recommended to code CSS to work in a mobile phone as default and make a post stylization for desktop.
/* CSS For Mobile */
@media screen and (min-width: 768px) {
/* CSS For Desktop */
}