DEV Community

avcat
avcat

Posted on

Modern CSS reset?

Previously I have been using sanitize CSS reset. In practice it turned out to be quite extra and still needed tweaking.

For now my approach is: the simpler = the better. The CSS reset from Josh Comeau is quite simple and modern: as you may see, it uses newer properties for text-wrap and interpolate-size. In the linked article you will find explanations for all the properties used.

/*
  Josh's Custom CSS Reset
  https://www.joshwcomeau.com/css/custom-css-reset/
*/

*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

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

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
}

#root, #__next {
  isolation: isolate;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)