Notes on Codecademy "Learn CSS"
After going through Codecademy courses on HTML and JavaScript, the next obvious step for me was to visit the third pillar of the modern web: CSS. There's a bit of weirdness with the class listing, though. It seems Codecademy is reorganizing offerings in this area. I took the "Learn CSS" class listed at the top of their HTML/CSS section and afterwards, I discovered it was actually a repackaging of several smaller CSS courses.
- Learn CSS: Introduction
- Learn CSS: Box Model and Layout
- Learn CSS: Colors
- Learn CSS: Typography and Fonts
Either that, or the reverse: Learn CSS course is being split up into these multiple smaller courses. I'm not sure which direction it is going, but I expect this is a temporary "pardon our dust while we reorganize" situation. The good news is that their backend tracks our progress through this material, so we get credit for completing them no matter which course was taken.
Anyway, onward to the material. CSS determines how things look and lets us make our pages look better even if we don't have professional design skills. My first nitpick had nothing to do with appearance at all: in the very first introductory example, they presented a chunk of HTML with DIV tags for header, content, and footer. My first thought: Hey, they didn't use semantic HTML and they should!
Most of the introductory material was vaguely familiar from my earlier attempts to learn CSS. I hadn't known (or had forgotten) that attribute selectors had such a wide range of capabilities, almost verging on regular expressions. The fancier pattern matching ones seem like they could become a runtime performance concern. Selector chaining (h1.destination
covers all H1 tags with class="destination") is new to me, as was descendant combinator (.description h5
covers all H5 tags under something (not the H5) with class="description"). I foresee lots of mistakes practice keeping them straight alongside multiple selectors (.description,h5
covers H5 tags and tags with class="description" equally, without requiring any relation between them.)
In the realm of box model and layout, I have never found the default HTML content box model to be intuitive to my brain. I always thought of the border and padding as part of the element, so I expect I'll have better luck using box-sizing: border-box;
instead for my own layouts. What I don't expect to have a luck with is positioning. I've played with this before and relative/absolute/fixed/sticky always felt like voodo magic I didn't fully understand. It'll take a lot more practice. And a lot more examining of behavior in browser development tools. And if that fails, there's always the fallback layout debug tool of putting a border around everything:
* { border: 1px solid red !important; }
And finally, I need more practice to get an intuitive grasp of how to specify values in CSS. Most of this course used pixels, but it would be nice to design style sheets that dynamically adjust to content using other units like em or rem. (Unrelated: this URL is in the MDN "Guides" section which have other helpful-looking resources.) I also want to make layouts dynamic to the viewport. We have a few tools to obtain such values: vw is viewport width, vh is viewport height, vmin is the smaller of the two, vmax is the larger of the two. On paper vmin+vmax can tell me if the screen is portrait or landscape, but I haven't figured out the logic for a portrait layout vs. landscape layout. Perhaps that is yet to come in later Codecademy CSS courses.