Performs calculations with mixed units.
div {
width: calc(100% - 40px);
height: calc(100vh - 80px);
}
Pick the smallest or largest value from a list.
div {
width: min(800px, 100%);
font-size: max(1rem, 2.5vw);
}
Clamps a value between a minimum and maximum.
p {
font-size: clamp(1rem, 2.5vw, 2rem);
}
clamp() is perfect for fluid typography that scales gracefully across screen sizes.
Remove whitespace, comments, and unnecessary characters to reduce file size.
/* Before */
h1 { color: blue; font-size: 24px; }
/* After minified */
h1{color:blue;font-size:24px;}
<head> for above-the-fold content.Ensure sufficient contrast between text and background colors (WCAG AA requires a ratio of at least 4.5:1).
body {
color: #1a1a1a;
background: #ffffff;
}
Always provide visible focus indicators for keyboard users.
a:focus,
button:focus {
outline: 2px solid #3b82f6;
outline-offset: 2px;
}
Hide text visually while keeping it accessible to screen readers.
.sr-only {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
}
Use semantic HTML elements and style them with CSS for a clear, accessible page structure.
<header>
<nav>...</nav>
</header>
<main>
<article>...</article>
<aside>...</aside>
</main>
<footer>...</footer>
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
main {
display: grid;
grid-template-columns: 1fr 300px;
gap: 20px;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
footer {
margin-top: auto;
}
Build a semantic page layout with <header>, <nav>, <main>, <aside>, and <footer>. Add skip navigation, visible focus styles, and use clamp() for responsive font sizing.