How to hide div element when screen size is smaller than a specific size with CSS?

Sometimes, we want to hide div element when screen size is smaller than a specific size with CSS.

In this article, we’ll look at how to hide div element when screen size is smaller than a specific size with CSS.

How to hide div element when screen size is smaller than a specific size with CSS?

To hide div element when screen size is smaller than a specific size with CSS, we use media queries.

For instance, we write

@media only screen and (max-width: 1026px) {
  #fadeshow1 {
    display: none;
  }
}

to check if the screen size has width less than or equal to 1026px.

If it is, then we hide the element with ID fadeshow1 with display: none;.

Conclusion

To hide div element when screen size is smaller than a specific size with CSS, we use media queries.