Reset CSS β
Custom Reset CSS is a set of CSS rules that provide a consistent and clean starting point for styling web pages. This reset is designed to remove default browser styling and provide a foundation for building our own styles.
Box Sizing Rules β
By default, all elements have a content-box box sizing, which can lead to unexpected layout issues. This reset changes the box sizing for all elements and their pseudo-elements to border-box. This ensures that padding and borders are included in the element's total width and height.
*,
*::before,
*::after {
box-sizing: border-box;
}Remove Default Margins β
This section removes the default margins from various elements like headings, paragraphs, figures, and more. By doing this, you prevent any unexpected margin values applied by the user-agent stylesheet from interfering with our spacing choices.
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
margin: 0;
}Remove List Styles β
Lists (ul and ol) that have a "list" role attribute are unstyled. This is helpful when you want to create our own list styles and avoid the default bullet points or numbering.
ul[role='list'],
ol[role='list'] {
list-style: none;
}Set Core Root Defaults β
This rule ensures that when an element within the HTML document is focused, it will scroll smoothly.
html:focus-within {
scroll-behavior: smooth;
}Set Core Body Defaults β
This section sets some core defaults for the <body> element. It defines the minimum height of the body, optimizes text rendering speed, and sets the line height to create a more legible text layout.
body {
min-height: 100vh;
text-rendering: optimizeSpeed;
line-height: 1.5;
}Style Anchor Elements β
Anchor (<a>) elements without any class receive default styles. This rule ensures that links without specific styles still have text decoration behavior, such as skip-ink for better visual rendering.
a:not([class]) {
text-decoration-skip-ink: auto;
}Make Images Easier to Work With β
Images (<img>) and picture elements are configured to have a maximum width of 100% and a display property of block. This makes them responsive by default and easier to work with when adding images to our pages.
img,
picture {
max-width: 100%;
display: block;
}Inherit Fonts for Form Elements β
Form elements like input, button, textarea, and select inherit their font styles, ensuring consistency throughout our pages.
input,
button,
textarea,
select {
font: inherit;
}Table Styling β
This rule collapses table borders to avoid unwanted spacing and styling issues in tables.
table {
border-collapse: collapse;
}Accessibility and Reduced Motion β
For users who prefer reduced motion, this media query adjusts the scroll behavior, disables animations, and transitions for a more accessible experience.
@media (prefers-reduced-motion: reduce) {
html:focus-within {
scroll-behavior: auto;
}
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}