CSS
Modern CSS techniques for better layouts, responsive interfaces, cleaner stylesheets, and solving everyday front-end development challenges.
Browse 97 articles in this topic. View all topics.
- Selecting empty elements with CSS :empty
Use the CSS :empty selector to find elements with no child elements or text.
- Changing the text cursor with CSS caret-color
Change the colour of the text insertion cursor with the CSS caret-color property.
- CSS variables make repeated values easier to manage
Reuse values, provide fallbacks, and update themes with CSS custom properties.
- Set link underline styles with text-decoration
Set a text decoration's line, style, and colour with one CSS declaration.
- Centering flexbox items
Center flexbox items horizontally, vertically, or in both directions with two CSS properties.
- Use autocomplete=new-password for new password fields
Tell browsers that a password field is for choosing a new password rather than entering an existing one.
- Using CSS without getting in the way of accessibility
Practical CSS choices for readable text, visible focus, reduced motion, and layouts that survive zoom.
- Adding Outlook-only CSS to an HTML email
Load Outlook-specific email styles with Microsoft conditional comments.
- Using small caps with CSS font-variant
Use the CSS font-variant property to enable typographic variants such as small caps.
- A simple print style sheet for your website
Add print-specific CSS with a separate stylesheet or an @media print rule.
- Responsive web design starts with flexible defaults
Build responsive layouts with flexible CSS, useful breakpoints, and images that fit the screen without wasting bandwidth.
- Style Selected Text With CSS
Use the CSS selection pseudo-element to change the colours applied when someone highlights text on a webpage.
- Different CSS for touch and mouse input
Use pointer and any-pointer media features to adapt controls to coarse touch input, precise pointers, or devices with several input methods.
- Marking Up Keyboard Input With HTML kbd
Use the HTML kbd element to mark up keyboard keys and other input in instructions, with a small styling example.
- You can transition z-index
CSS can transition z-index, but because it is an integer the change happens in steps rather than as a smooth visual animation.
- Rename Downloads With the HTML download Attribute
Use the HTML download attribute to suggest a clearer filename when someone downloads a file from your site.
- A few CSS tricks and old browser hacks
A collection of small CSS tricks, including generated content, print breaks, Unicode selectors, and a few historical browser hacks.