A bare-bones CSS reset for modern web development.

Related tags

CSS modern-css-reset
Overview

A modern CSS reset

The Uncompressed size of this reset The GZIP size of this reset The Brotli size of this reset License: MIT

A tiny little reset that you can use as the basis of your CSS projects. You can read a breakdown of it here.

Installation

NPM:

npm install --save-dev modern-css-reset

Yarn:

yarn add modern-css-reset

Unpkg CDN:

<link rel="stylesheet" href="https://unpkg.com/modern-css-reset/dist/reset.min.css" />

jsDelivr CDN:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/modern-css-reset/dist/reset.min.css" />

Manual installation

First, let's clone this repository:

git clone https://github.com/hankchizljaw/modern-css-reset.git

Then, go to modern-css-reset directory:

cd modern-css-reset

And now, you can minify and move the main reset to the dist by running:

npm run build

That's it! πŸŽ‰

License

MIT

Comments
  • Adding padding-inline-start: 0px;

    Adding padding-inline-start: 0px;

    Hey everyone! So, I've been using this CSS reset on some client and personal projects and I've noticed that my layouts constantly get out of shape because of user agent styling on Microsoft Edge (haven't tested this on any other browser). This user agent styling applies a padding-inline-start of 40px. I was constantly being bamboozled by this issue and it would be helpful to add

    padding-inline-start: 0px;

    to somewhere in the reset

    Let me know what you think!

    Best, Benjamin Lebron

    opened by BenTechCoder 10
  • Make everything `position: relative`

    Make everything `position: relative`

    This is something @davidkpiano talks about and at first I was not on board and even made fun of him about it, but the more I think about it, the more I like it.

    Possible benefits

    • Predictable parent relationships for absolute children
    • Stacking becomes easier (yes I know there's a plethora of ways that you can affect stacking order)
    • The potential of a lot less CSS written. The chances of removing relative for static etc are likely to be way lower that you’d add relative

    I’ve been thinking about it again when he and Shaw were on ShopTalkShow, which is worth a listen.

    It’s worth remembering that a lot of stuff in this reset goes against the browser defaults, so this one, albeit way against browser defaults fits in nicely IMO.

    I’m opening this up for discussion because I might be missing a big issue here which I really don't want to create.

    opened by Andy-set-studio 9
  • Proposal: changes to lists

    Proposal: changes to lists

    Right now, the reset removes all padding, margin and list styles from lists that have a class attribute. This is causing problems in the community and it's something I'd like to remedy.

    Proposed change

    I propose that margin and padding are left as they are. They can be removed on a per-context basis, as required. The immediate removal is my preference and as this thing has exploded in popularity, that really doesn't hold water anymore.

    With those removed, I also propose that list styles are only removed when the list has a role of list on it, like so:

    <ul role="list"></ul>
    

    This is because, frustratingly, the list-style: none rule can cause problems for assistive technology.

    Old CSS

    
    /* Remove default padding */
    ul[class],
    ol[class] {
      padding: 0;
    }
    
    /* Remove default margin */
    body,
    h1,
    h2,
    h3,
    h4,
    p,
    ul[class],
    ol[class],
    figure,
    blockquote,
    dl,
    dd {
      margin: 0;
    }
    
    /* Remove list styles on ul, ol elements with a class attribute */
    ul[class],
    ol[class] {
      list-style: none;
    }
    

    New, proposed CSS

    /* Remove default margin */
    body,
    h1,
    h2,
    h3,
    h4,
    p,
    figure,
    blockquote,
    dl,
    dd {
      margin: 0;
    }
    
    /* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
    ul[role="list"],
    ol[role="list"] {
      list-style: none;
    }
    

    Comments welcome.

    enhancement discussion 
    opened by Andy-set-studio 7
  • It's normalize or it's reset?

    It's normalize or it's reset?

    Hello! It's perfect idea to store so much good practices in a single CSS file available from NPM.

    But some styles can cause a problems.

    1. I do not want to use all images as block. Sometimes I want to inline an image, and browser default is inline.

    /* Make images easier to work with */
    img {
      max-width: 100%;
      display: block;
    }
    

    I suggest to remove display: block from here.

    2. I do not always want to get some margins somewhere in article.

    I can use this tag for very custom design, and top margin on each child is not what I want. If I want vertical margins between elements, I use <h1> and <p>.

    /* Natural flow and rhythm in articles by default */
    article > * + * {
      margin-top: 1em;
    }
    

    I suggest to remove this part.


    All other code is amazing, I want to use it on every website I make.

    opened by Grawl 5
  • Reset box-sizing on html and inherit everywhere else

    Reset box-sizing on html and inherit everywhere else

    As stated in this article https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ , quoting @jonathantneal:

    This will give you the same result, and make it easier to change the box-sizing in plugins or other components that leverage other behavior.

    This is just a suggestion, feel free to refuse it! 😁

    opened by nhoizey 3
  • Resetting `ul` and `li` inside of `nav` element

    Resetting `ul` and `li` inside of `nav` element

    When using the nav element, ul and li are generally custom styled and does not need default margin or padding. Suggesting to remove the padding and margin on ul and li items inside of nav element.

    I can't really think of an instance where the nav tag is used for a generic ul.

    Also added a postinstall script so that the /dist files are automatically generated when npm install is ran.

    opened by standingdreams 3
  • Make animations end instantly instead of not run

    Make animations end instantly instead of not run

    If anything depends on the animation to be visible, it will still be visible. Could probably keep paused in there as well

    Demo comparison: https://codepen.io/psimyn/pen/KKPOgOQ

    Thanks for the excellent reset & write-up!

    opened by psimyn 3
  • Use uglifycss as dev dependency

    Use uglifycss as dev dependency

    Since the uglify dependency is used as a development tool in this project, it can be moved to the dev dependencies and not be installed in consuming projects if not needed.

    opened by jneander 3
  • Cross browser compatibility for hidden attribute: forcing

    Cross browser compatibility for hidden attribute: forcing "display: none"

    opened by yaaax 2
  • Only allow smooth scrolling when focused in the page

    Only allow smooth scrolling when focused in the page

    I saw in a recent tweet that using scroll-behavior: smooth can affect the default browser search feature, which could cause the page to scroll unnaturally back and forth as someone tabs through the results of the search. Suffixing the html selector with :focus-within means that the smooth scrolling will only happen when people are interacting with the page and anything within it.

    I've also prevented smooth scrolling when people prefer reduced motion

    Original credit to this article: https://css-tricks.com/fixing-smooth-scrolling-with-find-on-page/

    Edit: Tested on a production site using this same reset library πŸ‘πŸ»

    opened by daviddarnes 2
  • Specificity conflict with .flow utility and ul[class]

    Specificity conflict with .flow utility and ul[class]

    Hi,

    I'm using the reset along with the CUBE CSS methodology. I have a container with a .flow class applied:

    .flow > * + * {
        margin-top: 1rem;
    }
    

    Inside this container there are several elements (h1, p, ul…). The top margins are applied correctly, so the vertical rhythm is correct:

    <div class="flow">
    <h1>Lorem</h1>
    <p>Ipsum</p>
    <ul>…</ul>
    </div>
    

    However, if I add a ul which has a class, it doesn't respect the flow, because this rule in reset.css:

    body,
    h1,
    h2,
    h3,
    h4,
    p,
    ul[class],
    ol[class],
    figure,
    blockquote,
    dl,
    dd {
      margin: 0;
    }
    

    This selector: ul[class] has a higher specificity than .flow > * + *, so the top margin isn't applied.

    How would you tackle this situation? What do you think about changing ul[class] and ol[class] with just ul and ol?

    opened by Zubrik 2
  • global box-sizing: border-box;

    global box-sizing: border-box;

    should we use:

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

    better than

    /* Box sizing rules */
    *,
    *::before,
    *::after {
      box-sizing: border-box;
    }
    
    opened by snowdream 2
  • Remove `line-height` from `body`

    Remove `line-height` from `body`

    The line-height property with a value of 1.5 is a good default value, but maybe something opiniated that could be removed, because it will certainly be adjusted according to the design needs.

    Another reason is that WordPress (and maybe other tools) allows us to generate some styles from a json file. As these base styles are declared before any other stylesheet, we can't use the generated value for line-height because it will be loaded too early and overloaded.

    Would you accept a PR to remove that property?

    opened by benoitchantre 1
  • webkit min-height error

    webkit min-height error

    here is wrong way min-height: 100vh; for body because webkit not valid and on iPad it will count + height of submenu (tab bar)... recomendation - min-height: 100%;

    opened by am35a 2
  • Firefox bug with select and focus-within + scroll-behavior: smooth

    Firefox bug with select and focus-within + scroll-behavior: smooth

    Hello!

    I've been using your reset for a while (it's great btw thanks), and I've noticed a weird bug on Firefox (87.0) and Ubuntu. When I click on a select element, the dropdown appears for a fraction of a second, then disapears (I need to click again to have the regular select behaviour). Then if I move the focus elsewhere, and click again on the select, nothing appears on the first click.

    I've tracked down the problem to this part of the reset

    html:focus-within {
      scroll-behavior: smooth;
    }  
    

    I've made a codepen so that you can try and see if you can reproduce the issue https://codepen.io/kimlai/pen/PoWjMyv.

    I don't know what's happening, and it's most probably a bug in Firefox, but I thought that I'd let you know, since it makes the reset unusable as is (at least for me).

    opened by kimlai 1
Owner
Andy Bell
Educator and designer who runs https://piccalil.li and https://front-end-challenges.club. Co-author of https://every-layout.dev.
Andy Bell
A tiny modern CSS reset

minireset.css A tiny modern CSS reset that covers the basics: resets the font sizes: so that using semantic markup doesn't affect the styling resets t

Jeremy Thomas 2.6k Dec 29, 2022
🚿 A modern CSS reset

Modern CSS reset Installation npm install --save ress or bower install --save ress Features Apply box-sizing: border-box; in all elements. Reset paddi

● filipe 1.9k Jan 4, 2023
Spectre.css - A Lightweight, Responsive and Modern CSS Framework

Spectre.css Spectre.css is a lightweight, responsive and modern CSS framework. Lightweight (~10KB gzipped) starting point for your projects Flexbox-ba

Yan Zhu 11.1k Jan 8, 2023
A modern, responsive CSS boilerplate library to kickstart any web-based project.

Peacock CSS Peacock is a modern, responsive CSS boilerplate library to kickstart any web-based project. It is simple, lightweight and it contains all

Binary Birds 8 Jan 23, 2022
A utility-first CSS framework for rapid UI development.

A utility-first CSS framework for rapidly building custom user interfaces. Documentation For full documentation, visit tailwindcss.com. Community For

Tailwind Labs 63.5k Dec 30, 2022
A utility-first CSS framework for rapid UI development.

A utility-first CSS framework for rapidly building custom user interfaces. Documentation For full documentation, visit tailwindcss.com. Community For

Tailwind Labs 63.5k Jan 1, 2023
Modern CSS framework based on Flexbox

Bulma Bulma is a modern CSS framework based on Flexbox. Quick install Bulma is constantly in development! Try it out now: NPM npm install bulma or Yar

Jeremy Thomas 46.6k Dec 31, 2022
A classless CSS framework to write modern websites using only HTML.

new.css new.css A classless CSS framework to write modern websites using only HTML. It weighs 4.8kb. All it does is set some sensible defaults and sty

null 3.6k Jan 3, 2023
A modern alternative to CSS resets

normalize.css A modern alternative to CSS resets NPM npm install --save normalize.css CDN See https://yarnpkg.com/en/package/normalize.css Download Se

Nicolas Gallagher 49.4k Jan 5, 2023
A modern alternative to CSS resets

A modern alternative to CSS resets

Nicolas Gallagher 49.4k Jan 1, 2023
Skeleton: A Dead Simple, Responsive Boilerplate for Mobile-Friendly Development

Skeleton Skeleton is a simple, responsive boilerplate to kickstart any responsive project. Check out http://getskeleton.com for documentation and deta

Dave Gamache 18.8k Dec 29, 2022
Playground for GNOME development

Workbench Playground for GNOME development Workbench aims to provide a great developer experience for the following use cases An application to learn

Sonny Piers 344 Jan 5, 2023
Simplify gnome-extensions development

GISP GISP Is a Starter Pack About GISP is a project to simplify ?? gnome-extensions development. There're hundrends (maybe thousands?) of javascript d

Leandro SimΓ΅es 3 Jul 18, 2022
Low-level CSS Toolkit – the original Functional/Utility/Atomic CSS library

Basscss Low-level CSS toolkit – the original Functional CSS library https://basscss.com Lightning-Fast Modular CSS with No Side Effects Basscss is a l

Basscss 5.8k Dec 31, 2022
Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation

Aphrodite Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation. Support for colocating y

Khan Academy 5.3k Jan 1, 2023
CSS Boilerplate / Starter Kit: Collection of best-practice CSS selectors

Natural Selection Natural Selection is a CSS framework without any styling at all. It is just a collection of selectors that can be used to define glo

FrontAid CMS 104 Dec 8, 2022
Source code for Chrome/Edge/Firefox/Opera extension Magic CSS (Live editor for CSS, Less & Sass)

Live editor for CSS, Less & Sass (Magic CSS) Extension Live editor for CSS, Less & Sass (Magic CSS) for Google Chrome, Microsoft Edge, Mozilla Firefox

null 210 Dec 13, 2022
Easily create css variables without the need for a css file!

Tailwind CSS Variables This plugin allows you to configure CSS variables in the tailwind.config.js Similar to the tailwindcss configurations you are u

Mert Aşan 111 Dec 22, 2022