I think about and enjoy very boring CSS stuff—probably much more than I should do, to be honest. One thing that I’ve probably spent too much time t...
For further actions, you may consider blocking this person and/or reporting abuse
Well, this list is soooo arguable.
At first, AFAIK adding
list-style: none
resets accessibility of lists, so it's better to apply transparent image tolist-style-image
.Article with owl selector — really? I mean, if it is a reset for blogs, this thing should be boilerplated, but for all the possible cases do we all really need it? 'Cause
article
tag is used not just to markup text articles in magazines :)And of course images shouldn't be blocks by default (you are proposing reset, aren't you?). If you don't like image's gap at the bottom, just add
vertical-align: middle
— and the 'problem' is solved.I actually tend to agree with this. A reset should align browser defaults, whereas what’s been proposed is more of a boilerplate. A reset should be able to be used in any project without drastically changing things, but rules like the owl selector, image block, reduced motion query does exactly that. While these may be great for some projects, I wouldn’t be comfortable blindly dropping this in as a reset.
I'd properly respond but I actually can't be arsed. Maybe actually reading the post again, but you do you 👍
Sorry but where do you answer this in the post? You talk about how the list looks but removing the semantics is completely a different thing and I can't think why you'd want to use a list element without it carrying those semantics.
Anyway, thanks for the post, it's made me revisit what is really needed again.
Hello,
I just read your article, and there is one point that bothers me in this CSS reset.
For example, your idea of removing "list-style" and "padding" on "ul [class]" has too much of a too powerful selector.
Imagine that I want to change the style of UL with a "class", I will logically use ".my-list", but your selector will be more powerful. And I could not change neither the "padding" nor the "list-style", it is absolutely necessary to put more selector:
Your CSS reset is therefore not compatible with the BEM method for example. en.bem.info/methodology/css/
I would tend to let the developer choose if he needs to delete or not the style on with a "class"
How about adding an
overflow-x: hidden
to the body?I'm up for that. Great idea!
Not a great idea! This'll kill
position: sticky
for all the child elements.Oooh good point!
The mental leap for that is a tough one for me. Why isn't my position: sticky; working?! Oh, because some parent element has hidden X overflow? 🤯
Yup. I completely forgot about that bugger. Definitely not helpful to be set as a global style in that context.
Finally I figure it out too :)
Apparently if you set the height of the element you're overflow hidden'ing on, sticky will work. So something like:
Just be careful with CSS and contain within something else overflow-x: hidden; as needed. Generic reset rules about body overflow just paper over cracks
What do you think about adding something like this:
or even:
I seem to always be removing margin top on the first item and margin bottom on the last item, since it pushes a container out too far or something.
I'm not sure if it's a good idea to reset styles for only
ul
andol
elements that have a class. I'm guessing the rationale behind this decision was to remove default styling for elements that are semantically lists.But consider the following case where the user is expecting default styling on a
ul
element, plus an added purple style for the text:In this case, the default margin and padding would be removed and AFAIK there isn't a way to restore the default UA styling.
Yeh that's valid, but I've found the styles as above more useful. It's probably better for you to create a fork in this instance.
Very nice, Andy. I'll consider using it from now on 👍
I was wondering about the
box-sizing
setting selector: isn't*::before
equivalent to just::before
?I'm asking because I've seen that everywhere with the asterisk, so I wonder if there are any differences I'm missing out.
Both will work fine! It's just a stylistic choice, really.
Does this:
can just be like this?
It's in the media query for if someone prefers reduced motion. Your code will just disable animations globally.
Yes sorry, i forgot to add the @media query. By point was about the values (unset, revert, initial). But i think forcing specific value is more stronger, while my proposed values are not predictable.
Yeh, sure you can do that!
Thanks for a great reset! Really liked the smart list styling.
But can't agree with the prefers reduced motion part. This option is for people who wants reduced motion. Not no motion at all. A lot of small animation can be critical to understanding the flow or function, without triggering motion sickness or nausea.
Also opacity and color changes usually works just fine to.
Well I could rant over this for hours, but I guess you get my point 😄. Devs always need to add this media query on problematic animations (also in JS code), but that must be up to the author of the code to decide.
I disagree. The great thing about it being OS is that you can fork it and remove the bits you don't like 🎉
Absolutely. Just know how copy paste friendly this community is, many developers will just take it and don't think what it does. Just wanted to make sure people know what it does.
But will definitely try this on my next project. Thanks!
I'm curious whether the
text-rendering: optimizeLegibility;
avoidance is still applicable. That article is from 7 years ago, which is an eternity in terms of phone age. It'd be nice to see a set of updated measurements!You've missed the h5 tag.
how about
h6
? :DAmazing work !!! well done
Great list!
I always add:
font-size: 0
to the body element, to disable the gap when you use display: inline-block
I would only recommend doing hacks like that on the element itself, rather than globally.
I use inline-block pretty often. It’s a necessity for me.
But not everybody has the same approach. Thanks for your post again. Very helpful
Interesting technique. Does that no longer have SEO issues? Maybe the crawler is smart enough to go further into the page, but I remember that being a solid anti-pattern a while back.
I don't think so, but should be tested :)
element, then you don't plan to have text directly in the body element. The text should be inside of aMy opinion is that if you put "font-size: 0" to the
,
or other (all with a visible font-size). Nothing is concealed, so it should be crawled normally.
Pretty good stuff. One question for you. In the anchor element section you mention "This could be set on links globally, but it’s caused one or two conflicts in the past for me, so I keep it like this." I'm curious what those conflicts were.
Thanks for this, Andy! I've been using something similar that I have created, however, it's definitely not as robust. I'll definitely be borrowing some of this!
Have you considered using
rem
instead ofem
on this part? (so the margin is relative to document font size)em
is relative to the element in question’s size, which I’ve found generates a nice, natural rhythm. I went into more detail usingrem
units in this article, last year,Thanks for the article Andy, I'll definitely create mine based on this one. :)
One question though: Why don't you use more reset on buttons?
Adding
height: auto
to image can be useful with svg images. I had some issues with brand logo and illustrations in content.Thank you very much for the resetCSS and the breakdown. Will use it for the next project.
This was a very cool read - the "lobotomized owl" in particular was new to me and definitely something I'll incorporate now. Thanks! 😊
It's pretty heavy-handed. If you want to get more granular - check out this type of selector.
I prefer to keep the default margin / padding on elements, since it requires less CSS to set this back to a real value and I can't e.g. forget to style an element which is added dynamically
Thank you!
Hi, I'd like to translate this article to Chinese, and publish the translation at nextfe.com Can you give me the permission to translate it?
Thanks! I was looking for a new reset.css! :-)
What if text-rendering: optimizespeed placed to html part rather than body part?
You could do that if you want, sure!