Skip to content

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.

css
*,
*::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.

css
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.

css
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.

css
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.

css
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.

css
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.

css
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.

css
input,
button,
textarea,
select {
  font: inherit;
}

Table Styling ​

This rule collapses table borders to avoid unwanted spacing and styling issues in tables.

css
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.

css
@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;
  }
}