Getting to d3.js: Intermediate CSS
Continuing on with CSS, the next stop in this journey is a course on Intermediate CSS.
My first lesson was on why the C in CSS stands for Cascading. This all basically comes down the hierarchy of how the rules are applied. The four broad categories that determine the overall level of importance are:
position
specificity
type, and
importance
Check out this resource for more detailed information on how this works.
The next lesson was on combining CSS Selectors.
This lesson took the one from above a step further in explaining how you can get very specific to the elements you are wanting to apply your style.
The different ways to combine CSS selectors reviewed were:
group rule
this is done with a comma and it works by selecting both selectors and applying the same style
selector, selector {color: blue} - the result would be both selectors are blue
child
this is done with the use of two selectors, the first selector is the parent selector and the second selector is the child selector
selector > selector {color:blue} - the result of this would be where the child selector exists inside the parent selector, it would be blue
descendant
this one uses a single space, and it means that the style of selector after the space (descendant) is going to be applied as long as it has an ancestor that matches the first selector (ancestor).
selector selector {color: blue}
Below is a result of choosing the correct combination of selector to get this as the desired output:
Final Project: CSS Flag
This project was to use all of the things learned in the Intermediate section with the goal of creating the flag of Laos, with the text “The Flag of Laos” over top, with ‘The Flag’ and the top and center and ‘of Laos’ centered in the white circle of the flag.
Because the HTML provided was very barebones, this one was a little challenging in remembering the specificity rules. In real practice, you would probably use more ids and classes to define things, but we got there eventually!
And with that, Intermediate CSS is completed!
Up next: Advanced CSS