If you’re looking to elevate your CSS skills to a professional level, you’re in the right place! This article provides a comprehensive guide filled with essential pro tips that will help you tackle common CSS challenges effectively.
Table of Contents
Protips
1. Use a CSS Reset
A CSS reset removes default browser styling inconsistencies, helping maintain a uniform look across different browsers.
css
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
2. Inherit Box-Sizing
By allowing the box-sizing property to be inherited, you’re simplifying the process of managing layouts within your components.
css
html {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
}
3. Use unset Instead of Resetting All Properties
When resetting styles, you can simplify this using all: unset;, which reverts properties to their initial values efficiently.
css
button {
all: unset;
}
4. Use :not() to Apply/Unapply Borders on Navigation
Instead of applying borders individually, leverage the :not() pseudo-class for a cleaner approach:
css
.nav li:not(:last-child) {
border-right: 1px solid #666;
}
5. Check if Font Is Installed Locally
Ensure better performance by checking if a font is available locally before fetching it from remote sources:
css
@font-face {
font-family: 'Dank Mono';
src: local('Dank Mono'), url(...a.server/fonts/DankMono.woff);
}
6. Add Line-Height to Body
By setting the line-height on the body, you ensure that text inherits a nice spacing without repeated definitions:
css
body {
line-height: 1.5;
}
7. Vertically-Center Anything
By using flexbox or Grid, you can easily center elements both vertically and horizontally:
css
body {
display: flex;
align-items: center;
justify-content: center;
}
8. Use Aspect-Ratio Instead of Height/Width
This property helps maintain ratio consistency in responsive designs:
css
img {
aspect-ratio: 16 / 9;
object-fit: cover;
}
9. Use the Lobotomized Owl Selector
Utilize the universal selector in combination with adjacent sibling to apply styling consistently:
css
* + * {
margin-top: 1.5em;
}
10. Hide Autoplay Videos That Aren’t Muted
Prevent autoplay videos without sound from displaying:
css
video[autoplay]:not([muted]) {
display: none;
}
Support
Current versions of Chrome, Firefox, Safari, and Edge support these tips.
Translations
Due to time constraints, translations of tips are not consistently maintained. Check the original README file for complete updates.
Troubleshooting
- If you encounter issues with CSS properties not working, make sure to validate your CSS syntax.
- Cross-browser compatibility can be a common hurdle; ensure you are testing on multiple browsers.
- For any project-specific inquiries or assistance, don’t hesitate to reach out.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

