Introduction
I'm not trying to re-invent the wheel with this tutorial. There are plenty of comprehensive lessons on ways to use CSS and the tricks you can do. You can check out some of my favorites in the links section. Instead, I've created a bare-bones introduction to making static pages with CSS.
Why Learn CSS?
The short answer is because it gives you more control over how your content is presented in an HTML document. It's not just for the old-school, showcase style websites that I like to create. It's also great for customizing wordpress themes and even Twine games. The main reason coding hobbyists love it is because it's a timesaver. Instead of changing the code on multiple pages, you can keep a consistent appearance by editing ONE .css file.
HTML vs CSS
HTML is your content. The words on the page, the spacing, and the names of different sections. The CSS stylesheet tells your browswer what to do with each element. Let's take a look at the HTML and CSS for the file you're browsing right now:
The pane of the left is my HTML file. It has very little in the way of customization, and it doesn't specify colors. It just spells out 3 things: 1) the text you're reading. 2) the names of each section and 3) How things are spaced. This means you can create content from scratch without having to worry about spacing and positioning things right away. The file on the right pane is the CSS file, or stylesheet. (More on that in a minute).
What's a stylesheet?
CSS stands for Cascading Style Sheet. Basically, your stylesheet finds all the classes and IDs in your HTML file and tells the browswer how to display them. In order to transform your HTML file into a fairly boring-looking bit of text and blue links, you link to the stylesheet.
Here's what the header HTML for this page looks like:
Classes & IDs
In the HTML file, you may have noticed two bits of code that show up over and over
Selectors & Properties
The selector picks an element to change. The property decides how it looks. For example:
When you put it together, you have:
The semi-colon tells the browswer that you're done defining the selector, much like the ">" when coding HTML.
So, Now What?
Here some of the most common selectors:
Links