CSS => Too Complicated 😡

I'm a Web-Developer for about 4 years now and I love every aspect of it except for CSS. Don't get me wrong I do like CSS because it has so many possibilities. But that is kind of the problem. I'm currently building my own website and I'm struggling on how to setup my CSS. I'm developing all native but I was thinking switching to Bootstrap or something because designing isn't my specialty. I wanna start my CSS from zero so that all user agent styles are gone for my website but I also want to keep my CSS as little as possible. My head is currently exploding right now because I'm wasting time with this overcomplicated and stupid CSS language. Summary: I just want an easy and effective way to write CSS code without any issues with user agent styles and responsiveness.
74 Replies
CodeMoon07
CodeMoon07OP4mo ago
@Kevin Powell Now I don't know if its ok to tag you and if not I'm sorry but I really wanted you to see that as well.
13eck
13eck4mo ago
Don’t start your CSS from zero. Most of the defaults are well-thought out and work. There’s no reason to remove them. Indeed, there are many gotcha’s that you’ll run into if you try. Instead, adopt an additive approach: when you find something you don’t like, add a rule to change it. Use classes and descendant selectors liberally so you don’t run into specificity issues that frequently. And, when you feel like you need to add !important it’s time to reevaluate your CSS and find out where the bug is and fix it. Also, #📝rules 5️⃣ : no pinging Kevin (or mods) with questions
CodeMoon07
CodeMoon07OP4mo ago
your right Kevin also said in one of his videos that you should work with the browser and not against it but im worrying about that some user agent styles might ruin my site
ἔρως
ἔρως4mo ago
you cant stop that from happening just make sure it is accessible everything that the users do is out of your control, so, dont even think about it
13eck
13eck4mo ago
Don’t worry about what the end user does. You can’t stop them from doing anything. Only worry about what you do. Do your best. If the want to need things up that’s their problem
CodeMoon07
CodeMoon07OP4mo ago
i was thinking about building my own framework starting with the hard reset with: * { all: unset; } but im not sure how long it takes to setup most stuff again and what important rules i might forget to add back
ἔρως
ἔρως4mo ago
N nNO nono
13eck
13eck4mo ago
Don’t. That way lies madness
ἔρως
ἔρως4mo ago
that is like taking a rocket launcher and obliterating your house with you inside
13eck
13eck4mo ago
The only people who should be doing that are experts in design and the web. And that is a very few number of people indeed
CodeMoon07
CodeMoon07OP4mo ago
💀
ἔρως
ἔρως4mo ago
seriously, dont do it
13eck
13eck4mo ago
Use the default styles until you have a good reason to override
CodeMoon07
CodeMoon07OP4mo ago
so you guys say i should just write minimal css code working with the defaults and not against
13eck
13eck4mo ago
YES
ἔρως
ἔρως4mo ago
we didnt say minimal, but yed
CodeMoon07
CodeMoon07OP4mo ago
if yes then should i style include a box model reset with margin and padding etc none
ἔρως
ἔρως4mo ago
no that's like putting mines on your house and dancing around
CodeMoon07
CodeMoon07OP4mo ago
cmon man that cant be too harsh its just preventing layout defaults
ἔρως
ἔρως4mo ago
some elements will stop working properly if you do that for example, lists will have all sorts of issues
CodeMoon07
CodeMoon07OP4mo ago
wait lemme show you an example * { margin: 0; padding: 0; border: 0; } *, *::before, *::after { box-sizing: border-box; } your telling me thats bad
ἔρως
ἔρως4mo ago
the defaults for "layout" is no margin or padding
13eck
13eck4mo ago
The top is BAD. The bottom is good
CodeMoon07
CodeMoon07OP4mo ago
dayum
ἔρως
ἔρως4mo ago
but you are doing the reset for EVERYTHING
13eck
13eck4mo ago
Why? What benefit does this provide? Hint: none
ἔρως
ἔρως4mo ago
if you want to make it worse, add outline: none then it's trully cursed...
13eck
13eck4mo ago
Change things when you need to, ands there is literally no need to nuke padding/maring on everything
CodeMoon07
CodeMoon07OP4mo ago
guess what i did that in my early stages of css including other random stuff in the universal selector
13eck
13eck4mo ago
Advise the browser, don’t micromanage it
ἔρως
ἔρως4mo ago
that is horrible
CodeMoon07
CodeMoon07OP4mo ago
like resize both and overflow auto on EVERYTHING dont ask me why
ἔρως
ἔρως4mo ago
... cursed
CodeMoon07
CodeMoon07OP4mo ago
ik
ἔρως
ἔρως4mo ago
at least you didnt put the font-size to 62.5%
CodeMoon07
CodeMoon07OP4mo ago
yh wdym
13eck
13eck4mo ago
To go back to the topic as-written. CSS isn’t too complicated. You’re overcomplicating it
ἔρως
ἔρως4mo ago
if you have to delete a default, you better have a very good reason for it
CodeMoon07
CodeMoon07OP4mo ago
lemme find some old bad CSS code from me for fun
ἔρως
ἔρως4mo ago
there are some defaults you will want to change, like the width of inputs, the font of textareas and the margin around the body but if you nuke everything, you will add everything back, probably with the same exact values
CodeMoon07
CodeMoon07OP4mo ago
OH NAH I FOUND A CURSED EXAMPLE * { margin: 0; padding: 0; box-sizing: border-box; font-family: system-ui, Arial, Helvetica, tahoma, Verdana, sans-serif, monospace; outline: none; border: none; appearance: none; user-select: none; overflow: hidden; letter-spacing: 0.5px; } body { width: 100vw; height: 100vh; display: grid; place-items: center; overflow: auto; } that aswell @ἔρως
ἔρως
ἔρως4mo ago
that is cursed indeed
Kevin Powell
Kevin Powell4mo ago
Since you're asking... if you've got time to spare, it could be a good idea to try making a project starting with
* {
all: unset;
}
* {
all: unset;
}
just to see why you wouldn't want to do that 😄 - if you think css is too complicated, this will show you how sane the defaults are, and how much they simplify things! (Unlike the others here, I do like to remove the margin from most elements though... but it does mean re-introducing spacing in one way or another, and I also target the elements I want in my reset, like h1, h2, h3, h4, p, ul, ol) and I leave the default padding for lists, etc. Look up "modern css reset", there are a few good ones, like Josh Comeau's, Andy Bells, and 2-3 others that will be near the top of the search results, and they many (like Josh's and Andy's) come with a blog post explaining each line. You'll also notice that they are pretty simple, in general. They don't make any huge changes, just small tweaks. I should do a live stream where I start a project with all: unset 😄
13eck
13eck4mo ago
A really good "reset" to look at is Jen Simmon's CSS Remedy. It has comments explaining each item as to why it's there and what it does.
Unlike the others here, I do like to remove the margin from most elements though
– @Kevin Powell It's not that I don't think it should ever be done, but when someone isn't sure how CSS works it's a bad starting point. Learn the rules first before you break them, right? You can do it b/c you know what you're "breaking" by doing so, not so much for a lot of others :p
Kevin Powell
Kevin Powell4mo ago
good point, I already have things in place (or at least a plan in place) for how I'm going to deal with that 🙂
13eck
13eck4mo ago
Same advice given to writers: learn the tropes of your genre and why they're there. Once you know why they are then you can subvert them.
Kevin Powell
Kevin Powell4mo ago
One thing I will say, @CodeMoon07 is that it sounds like you are talking about writing CSS and designing the site in the same breath. You mentioned design isn't your specialty, and that's the thing with CSS, it's not about creating a design, but about making a design come to life in the browser. Actually creating the design for a good looking website is a totally different skillset. There are a lot of insanely talented CSS folks who don't have very good design skills, but they can take a given design from a static design file and make it come to life in the browser. If you're trying to design in the browser, but already struggle with CSS, it's going to be hard, because you're doing two things at once, both of which it sounds like you struggle with.
CodeMoon07
CodeMoon07OP4mo ago
Sorry for responding so late but I would love to see you stream with the all unset (If you haven't done that already). Honestly CSS is a great "language". Last night I was in a focus state designing my own website 😂. But the advice that really helped me is that you should work with the default and not against it. Kinda like Kevin once said in a video to work with the browser and not against it.
ἔρως
ἔρως4mo ago
when you start working against the browser, for absolutely no reason at all, you're on an uphill voyage on shit creek with no paddle just wasting time doing what the browser was already doing, and on top of that you have to fix what you broke
CodeMoon07
CodeMoon07OP4mo ago
My fav reset is just a box model reset and imgs etc to display block and 100% Your right
ἔρως
ἔρως4mo ago
also, set the font to italic on images
CodeMoon07
CodeMoon07OP4mo ago
For the alt text? Can i also do font style italic on videos and stuff or only on imgs
ἔρως
ἔρως4mo ago
yes, for the alt text so it makes it absolutely obvious that the text shouldn't be there
vince
vince4mo ago
Removing the browser defaults >>>>
CodeMoon07
CodeMoon07OP4mo ago
tell me how your doing it @vince
ἔρως
ἔρως4mo ago
he can't list it, because the bullet points are broken and misaligned
vince
vince4mo ago
A Modern CSS Reset • Josh W. Comeau
I have a set of baseline CSS styles that come with me from project to project. In the past, I'd use a typical CSS reset, but times have changed, and I believe I have a better set of global styles!
vince
vince4mo ago
And I'll remove default paddings on certain elements like lists
ἔρως
ἔρως4mo ago
which breaks lists that css reset has some issues
CodeMoon07
CodeMoon07OP4mo ago
lemme refine that reset to my likings
ἔρως
ἔρως4mo ago
point 2, 3, 4, 6, 9 and 10 have some issues
CodeMoon07
CodeMoon07OP4mo ago
This would be my version of the josh reset:
* {
margin: 0;
padding: 0;
border: none;
}

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

@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;
}
* {
margin: 0;
padding: 0;
border: none;
}

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

@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;
}
ἔρως
ἔρως4mo ago
2- breaks stuff 3- how does this help for someone who has reduce-motion set? 4- 1.5 is too big 6- it's missing the italic text for img 9- doesn't this cause performance issues for long paragraphs? 10- this doesn't do anything
CodeMoon07
CodeMoon07OP4mo ago
.2. just removes default layout .3. thats true that doesnt really help .4. 1.5 isnt too big its actually the prefered in typographie .6. true but its just a small point .9. idk .10. idk
ἔρως
ἔρως4mo ago
it doesn't "remove default layout" as it isn't part of layouting
13eck
13eck4mo ago
4. True for print, maybe. But this is the web—most print rules don’t apply
ἔρως
ἔρως4mo ago
1.5 on a title is MASSIVE
CodeMoon07
CodeMoon07OP4mo ago
yeah except for titles its good on p's
ἔρως
ἔρως4mo ago
1.5, depending on the font, is pretty eh
13eck
13eck4mo ago
This goes back to the prior idea of “know what you’re doing and do things with a purpose…and ‘someone else is doing it’ is a really bad purpose”
ἔρως
ἔρως4mo ago
by the way, use code blocks
CodeMoon07
CodeMoon07OP4mo ago
what do you mean with code blocks
CodeMoon07
CodeMoon07OP4mo ago
oh ok gotcha

Did you find this page helpful?