Do I have the gist of the purpose of CSS?
So I'm starting to understand the way we must think about CSS if we want to have a good relationship with it.
And after watching this amazing video: https://www.youtube.com/watch?v=aHUtMbJw8iA
I wanted to make sure that I got the gist of it β€οΈ
It all starts with the origins of the web. Tim Berners Lee specified that his purpose with HTML was to make it platform-agnostic, which is why it is quite easy to learn and use. As we know, this history ended up creating the idea of the web: a place where you could consume and share anything you wanted based on open standards with nothing more than a Wi-Fi connection.
Now, the nature of the web is way more different than other media such as music, print or video: in those, the creator controls the whole process and how the end users will consume it. Conversely, it is the consumers who control how they consume the information on the web, because of its openness and goal to be accessible to everyone no matter their physical disabilities, devices, intentions, preferences... You name it.
The browser has to handle all the aforementioned variables and more in order to give something to the end user, and this is where CSS comes into play, and is why the style sheets are cascading: because all the variables go through this cascade and result in something that can be given to the end user.
So we are getting nowhere trying to control the width of a box across devices, or complaining about the overflow default behaviours, or how our
height
declarations are causing issues: this isn't about controlling, this is about flexibility. It's ok to have CSS as a non-required presentation layer, but we have to accept it π
The bottom line is that as developers, we have to think about CSS as a way of communicating our intentions to the browser, not how it must literally behave. Let him do that for you β€οΈMozilla Developer
YouTube
Why Is CSS So Weird?
Love it or hate it, CSS is weird!Β It doesn't work like most programming languages, and it doesn't work like a design tool either. But CSS is also solving a very weird and unique problem: What does it mean to "design" in a medium that is appears on everything from tablets, laptops, and TVs to braille readers, watches, and headphones?
As the web...
4 Replies
It all starts with the origins of the web. Tim Berners Lee specified that his purpose with HTML was to make it platform-agnostic, which is why it is quite easy to learn and use. As we know, this history ended up creating the idea of the web: a place where you could consume and share anything you wanted based on open standards with nothing more than a Wi-Fi connection.Yes, HTML is a Markup Language, so that you're not shipping a program, just the content. And it's up to the client to display it. Also, back then, Wi-fi didn't existβthey used dedicated hard-lines for it. The Internet was originally designed for universities to share information. The world wide web grew out of that to what we think of as "the internet" today.
Now, the nature of the web is way more different than other media such as music, print or video: in those, the creator controls the whole process and how the end users will consume it. Conversely, it is the consumers who control how they consume the information on the web, because of its openness and goal to be accessible to everyone no matter their physical disabilities, devices, intentions, preferences... You name it.True! However, it was closer to print back then than now due to the fact that all computer monitors were the same size and had the same resolution. Early websites were a lot easier to make because we knew the dimensions of the end client. It's only the past 20 years or so that multiple sizes became an issue. But yes, the internet is more user-controlled than most devs and C-suite dorks want to believe π
The browser has to handle all the aforementioned variables and more in order to give something to the end user, and this is where CSS comes into play, and is why the style sheets are cascading: because all the variables go through this cascade and result in something that can be given to the end user.Yes. Though I believe that the cascade was done more for resource purposes than anything else. Only make changes the style sheet says so the browser doesn't need to do unneeded computations.
So we are getting nowhere trying to control the width of a box across devices, or complaining about the overflow default behaviours, or how our height
declarations are causing issues: this isn't about controlling, this is about flexibility. It's ok to have CSS as a non-required presentation layer, but we have to accept it π
I think that a lot of this stems from the early "this is like print, but online!" nature of the web. People try to apply previous design patterns to new things only to later discover that it's too new to rely on the old patterns. Hell, there are people who still believe that "above the fold" is a thing in web design, which is silly (well, it's dumb AF, but that's just my opinion). Also in the early '10s browsers weren't all on the same page as to how to display things, so there was a major push for "CSS resets" that made all browsers look pixel-perfect identical. Which is also silly. It's not like the average consumer is going to visit your site on Chrome today and Safari tomorrow. People learned (I hope!) that internal consistency is best.
The bottom line is that as developers, we have to think about CSS as a way of communicating our intentions to the browser, not how it must literally behave. Let him do that for you β€οΈYES THIS! Give the browsers suggestions, not orders. The browser is smarter than you because it knows more. It knows what size the viewport it. It knows if the viewport is portrait or landscape. What the default font size is. The zoom level, etc. You'll never be able to account for everything without shipping GiB of CSS. So just don't, yeah?
So suppossing what you tell is true, it would make much more sense that CSS is declarative and not like languages such as JS π€
Interesting!
I can't help but congratulate you for your excellent, well-written and complete feedback ππππππ
TYSM for your perspective β€οΈ
Let's keep making the web amazing for everyone!!!! π»πͺπΌ
By the way, the CSS Demystified course is the material whose purpose is helping you write CSS with this point of view, so check it out if you're interested π
beck is in the course with you π
Hahaha, I wrote the message just in case someone curious about this topic wanted to dig deeper π