← All tools

CSS Media Query Generator

Build mobile-first or desktop-first media queries from framework or custom breakpoints and a selector template.

css-media-query-generatorLOCAL WORKSPACE

Enabling local controls…

Settings

Use {bp} to insert a breakpoint name. Leave blank to use .{bp}. For custom breakpoints, use one name: width per line in px.

The framework presets provide common default widths in px. Check your framework version and project overrides before use.

Results

Breakpoints
NameWidth
sm640px
md768px
lg1024px
xl1280px
2xl1536px

CSS

/* sm */
@media (min-width: 640px) {
  .sm { /* Styles */ }
}

/* md */
@media (min-width: 768px) {
  .md { /* Styles */ }
}

/* lg */
@media (min-width: 1024px) {
  .lg { /* Styles */ }
}

/* xl */
@media (min-width: 1280px) {
  .xl { /* Styles */ }
}

/* 2xl */
@media (min-width: 1536px) {
  .\32 xl { /* Styles */ }
}
Download CSS

How to use this tool

Choose a preset or edit the controls. Copy the result or download it when it is ready.

When not to use it

The generated rule bodies are placeholders. Supply the styles your layout needs.