Lesson Details:
July 10, 2020
I: Introduction
A: Welcome to another exciting installment of my blog! I'm going to go over the basics of Cascading Stylesheets, a powerful tool for adding style to your WordPress code. Let's begin...
II: Body
A: Section 1: Anatomy of a CSS document
Cascading Style Sheets are a simple way to add a bit of style to your WordPress blog. Now, it's important to understand that CSS is not a programming language, but rather a markup language. The C in CSS stands for Cascading, and that's exactly what it does. In order to set up a style, you must use a "selector" to apply the style to. A selector could be any one of the following:
1) p
This selects all
tags on the page, and applies the style to them.
2) .post-title
This selects all
titles with a class called "post-title", and applies the style to them. (Remember how we used this earlier in our tutorial? This is the same thing!)
3) #main .post-title
This is an ID Selector, and in this case it selects an element with the ID of main, and applies the style to whatever element has that id (in this case, it would be the tag).
4) div.post p {color:red}
This is an example of an attribute selector , which can be used if you want to target certain attributes in your HTML. We'll discuss more on this in the advanced section!
5) body p {background-color: #ffffff}
This is an example of a descendent selector . It attaches itself to every element contained within the tag, and also applies the style inside it to all
tags contained within your
. You can read more about this here . This is not recommended though due to the fact that most experienced programmers will advise against it. For simplicity purposes, we're just gonna keep it at that! ;)
6) li * {color:#ffffff}
This is an example of an element selector . It selects EVERYTHING inside of a li tag, whether it be any text or other elements. This makes more sense when you see it in action, so take a look at the very last example. But make sure you understand how this works before you do! ;)
7) tr td {color:#ffffff}
This is an example of a nested element selector . This looks inside of a table row, finds every tag, then finds every tag that contains them, then selects each one of those rows for styling purposes. Pretty neat! :)
8) body p+p {font-size:10pt}
This is an example of a contextual selector . This finds every
tag that comes after another
tag, finds out what font size each one has, finds the largest font size of all of them, changes its font size to 10pts larger than that font size, and sets the rest of the paragraphs' font sizes to 10pts smaller than that font size. Neat huh? :) You can read more about this here . You'll also find some other cool stuff there too!
Write a public review