Transcript from the "Introduction" Lesson
>> Welcome everyone, my name is Jen Kramer. Today, we are going to be talking about HTML semantics and CSS specificity and selectors. So we have a lot of topics to cover today, we're gonna talk all about the various types of semantic HTML that can hopefully introduce you to a few elements you might not have heard before.
[00:00:18] We're going to talk a lot about CSS selectors and forming them, and what they mean. We're even going to get to some of the new ones like where n is and has, and some other various ones along the way, we're gonna talk about inheritance, specificity, and the cascade.
[00:00:36] So these are the three most misunderstood concepts in CSS. And as such, this is really a course about mechanics of CSS as opposed to how to make things pretty, and so more on that in just a moment. So as you follow along here, the course website is at semantics-selectors.css.education.
[00:01:00] Everything that I talked about today will be there including a copy of the slides, all of the code pins that we're going to work with, and links to GitHub. We'll actually only use GitHub and VS Code towards the end of the course, where we get to the cascade and we have to talk about different sources for stylesheets.
[00:01:17] Other than that, we're just pretty much going to work in CodePen today. So as I said, this is a course on CSS mechanics. And I have a number of other courses here in the front-end masters library if you want to work more on making it pretty. So if you wanna work on that, making it pretty stuff, the getting started with CSS course sounds pretty simple, it is a project-based course where we start with an Adobe XD, picture of how the site should look.
[00:01:44] We break it down into smaller pieces, and we put together the whole webpage as a portfolio site. We're not really going to focus so much on layouts or responsive design, they come up peripherally, but it's not a focus of this course, if you want to learn more about that, I have a course called CSS Grid and Flexbox for responsive layouts version two.
[00:02:03] If you watch my initial version of it, it was from like five years ago, the new version is completely updated with all kinds of new material, and you will learn new things in that one. And then, finally, advanced techniques in web dev specifically related to HTML and CSS, I have a course on that as well, the advanced CSS layouts course.
[00:02:23] And, of course, that is from 2019, so it's not going to have the very latest CSS selectors in it, but it does cover things like CSS variables and calkin, doing all kinds of crazy math to create different kinds of layouts for webpages, okay? Hopefully, that gives everybody a pretty good overview of where else you can go if there are other things you wanna learn about CSS.
[00:02:48] So let's start with what I see on Twitter and probably what you see on Twitter too, which is that <div> is totally awesome and we don't need anything else. It just does everything we need it to do, maybe the only other element that we need is a span element.
[00:03:02] And there is a place for absolutely everything on the web, you can find excuses to do absolutely anything with the right kind of website. Even though, that blinking spinning stuff does a really great thing on a hypnotist's website, so yes, there may be plenty of use for divs and spans, but there are better ways of doing things.
[00:04:23] I also hear things like CSS is stupid, it's unpredictable, I never know what I'm going to get. I hope that by the end of today that will no longer be an issue for you, it is very predictable, you can indeed predict what you're going to get. Specificity and the cascade should die.
[00:04:39] They are one of the most wonderful parts of CSS once you understand how they work and how to leverage them, it's amazing the tricks that you can do with CSS. And long live classes, the only part of CSS that makes sense, yes, classes are very useful on occasion.
[00:04:55] But I'm going to show you that when you expand your repertoire in terms of CSS selectors that are based on HTML semantics, you actually expand your depth of what you can do on the front-end. You stick to just classes and divs and spans, it's like having an old whole orchestra, but we're just gonna focus on the violin section.
[00:05:57] And look how much code we had to write in order to code a link because we did not know the a element in HTML. And we have made it even accessible here with our roll designation and so forth. I'm not saying this is good code but this is why this happens, because people do not understand HTML and do not know what's available to them.
[00:06:20] A good analogy to this is if we think about the construction industry in a very high level, we start with architecture and planning. They go in and play in a building, they pass it over to the construction people via blueprints. The blueprints describe what is going to be built, the construction people actually build it.
[00:07:10] We have the same kind of overlaps happening. We tend to think of UX UI and content all together as a unit. So those people are producing this content, along with their Figma prototypes and whatever else, they're gonna pass that on over to the development team that are going to put these things together.
[00:07:30] The overlapping part in the middle is the content of the webpage. Content is the moment that we transition from planning a website into building that website. And so we as developers, have a really bad habit of not reading the content. It is whatever it is, we don't care because we are so busy writing the code, and we are all guilty of this including me.
[00:07:52] I would actually start to argue at this point in time that content may be better delivered if it's actually marked up by the UX UI team first, and then pass to the development team. And the reason why is we wind up getting more semantics into it. And, of course, the development team could add any additional dudes or classes that are needed in order to completely lay out the page and so forth.