MyInternships.in

CSS References

CSS At-rules Reference

An at-rule is a CSS statement that begins with an @ sign and gives an instruction to the CSS engine — how to import a stylesheet, when to apply a block of rules, how to define an animation, or how to load a font. This reference lists the at-rules you will use most, with their syntax and purpose.


At-rules table

At-rulePurpose
@importImports an external stylesheet into the current one.
@charsetDeclares the character encoding of the stylesheet.
@mediaApplies rules only when the device/viewport matches a query.
@supportsApplies rules only if the browser supports a given feature.
@containerApplies rules based on the size of a container, not the viewport.
@keyframesDefines the steps of a named animation.
@font-faceDefines a custom font and where to download it from.
@pageStyles printed pages (margins, size, page breaks).
@propertyRegisters a typed custom property with defaults.
@layerDefines a cascade layer to control override order.
@namespaceDeclares an XML namespace for selectors (rare).
@font-feature-valuesNames OpenType feature values for font-variant.
@counter-styleDefines a custom list counter style.
@scopeScopes rules to a subtree, limiting where they apply.

@media — responsive design

Media queries are the backbone of responsive design. They apply a block of CSS only when conditions like viewport width, orientation or user preferences are met.

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  body { background: #111; color: #eee; }
}

@keyframes — animation steps

@keyframes slide-in {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.panel { animation: slide-in 300ms ease-out; }

@font-face — custom fonts

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@supports — feature detection

Use @supports to progressively enhance: give a solid baseline, then add modern layout only where it is supported.

@supports (display: grid) {
  .cards { display: grid; gap: 16px; }
}

@layer and @container — modern cascade and layout

At-ruleExampleWhat it does
@layer@layer reset, base, components;Declares an explicit order for cascade layers so later layers win predictably.
@container@container (min-width: 400px) { }Styles an element based on its container's size — component-level responsiveness.
@property@property --angle { syntax: "<angle>"; }Registers a custom property so it can be animated and type-checked.
💡

Add font-display: swap to @font-face so text stays visible with a fallback font while your custom font downloads.

Related CSS Topics

Keep learning with these closely related tutorials.

Ready to use your CSS skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships