SShortSingh.
Back to feed

CSS Media Queries Explained: How Websites Adapt to Different Screen Sizes

0
·1 views

A media query is a CSS feature that applies specific styles based on conditions such as screen width, orientation, or output type. Developers use media queries to build responsive websites that adjust their layout across devices like phones, tablets, and desktops without creating separate HTML files. The basic syntax combines the @media rule, an optional media type such as screen or print, and a condition like max-width or min-width. Common media features include min-width, max-width, orientation, and even user preferences such as dark mode. While specifying a media type like screen is valid, modern responsive design often omits it, making concise queries like @media (max-width: 768px) the standard practice.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How AI Coding Agents Like Claude Code Are Reshaping the Software Development Life Cycle

The traditional Software Development Life Cycle (SDLC) — spanning requirements, design, development, testing, deployment, and maintenance — is evolving as AI coding agents become active participants in the process. Tools like Anthropic's Claude Code can read codebases, edit files, run tests, and investigate failures, effectively functioning as a collaborative team member rather than just an assistant. Rather than replacing the SDLC, AI agents are being integrated within each stage, from brainstorming requirements and identifying edge cases to planning and testing. However, experts emphasize that human oversight remains essential — particularly in defining business goals, validating requirements, and making deployment decisions. For developers entering the field today, understanding how to work alongside AI agents within a structured development process is becoming a foundational skill.

0
ProgrammingDEV Community ·

AI Is Shifting Developers From Writing Code to Defining Intent and Owning Outcomes

A software developer argues that AI will not replace programmers but will instead shift their role to a higher level of abstraction, much like past transitions from assembly language to cloud platforms did. Historically, each major innovation in software engineering has moved developers away from low-level implementation toward problem-solving and system design. Today, tasks like defining requirements, evaluating trade-offs, and reviewing AI-generated code are increasingly where developer value lies. The author contends that deep technical knowledge remains essential, as it enables developers to understand what happens beneath the abstractions they use. Rather than becoming obsolete, developers are evolving into orchestrators of systems who focus on intent and outcomes rather than manual code translation.

0
ProgrammingDEV Community ·

Developer halves checkout API latency to under 900ms using AI-assisted debugging

A software developer reduced their checkout API's p99 latency from 2.1 seconds to under 900ms in a single afternoon by using Claude Code as a debugging partner. The performance issue had gone unnoticed for about a month until a support ticket flagged that checkout felt occasionally slow. By feeding real trace data to the AI tool, the developer discovered that orders with more than 12 line items were consistently the slowest, pointing to a non-linear scaling problem. The root cause turned out to be an O(n²) bug in the discount-application logic, where every line item triggered a full rescan of all items to check for bundle discounts. An earlier attempt to fix the issue by adding a database index had failed to improve p99 latency, underscoring that tail-latency problems often require targeted fixes rather than average-case optimisations.

0
ProgrammingDEV Community ·

Developer Builds Browser-Based Image Compressor That Never Uploads Your Files

A web developer created ImageSlim, a client-side image compression tool that processes JPG, PNG, and WebP files entirely within the browser, meaning images never leave the user's device. The tool was built in response to common frustrations with existing solutions, including privacy risks from server-based online tools, workflow disruptions from desktop software, and configuration overhead from CLI scripts. ImageSlim uses native browser technologies — the FileReader API, HTML5 Canvas, and the toBlob() method — to resize and compress images without any external dependencies or backend infrastructure. The developer addressed technical challenges such as memory limits on mobile devices for large files and correct handling of alpha transparency when converting PNGs to WebP. The project highlights the growing capability of modern browsers to perform tasks that once required server-side processing.

CSS Media Queries Explained: How Websites Adapt to Different Screen Sizes · ShortSingh