CSS Tutorial



CSS MEDIA QUERIES


CSS Media Queries

Media Queries allow CSS to adapt the layout and design depending on the device's screen size, resolution, or type (like print, screen, etc.).

๐Ÿ“ Syntax:

@media media-type and (condition) {
  /* CSS rules */
}

๐Ÿ”น Common Use Case:

Change layout based on screen width:

@media (max-width: 600px) {
  .box {
    background-color: #ffc107;
    font-size: 14px;
  }
}

๐Ÿงช Live Example:

Resize your browser window to see the box color change when screen width is 600px or less:

Resize Screen

๐Ÿ”ง Media Features You Can Use:

  • max-width and min-width
  • orientation: portrait / landscape
  • resolution
  • hover, pointer, aspect-ratio, etc.

๐Ÿ’ก Tips:

  • Use mobile-first design: start with base styles, then add media queries for larger screens.
  • Combine with flex/grid for powerful responsive layouts.

๐ŸŒŸ Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review