Finishing touches

This commit is contained in:
Oystein Kristoffer Tveit 2020-09-08 22:49:03 +02:00
parent 1514d33f1c
commit 92e6fa1297

View File

@ -2,7 +2,7 @@
## 1. Why does inline style CSS override rules defined in style elements and external stylesheets?
inline style CSS overrides external stylesheets because it's the most specific ruleset. Rules from external stylesheets might match the object, but if you know that this specific element should be styled differently, it could be written explicitly in the tag options of the element. However, best practise would be to use an ID.
inline style CSS overrides external stylesheets because it's the most specific ruleset. Rules from external stylesheets might match the object, but if you know that this specific element should be styled differently, it could be written explicitly in the tag options of the element. However, in this case it would be best practise to use an ID and specify the rules in a stylesheet.
## 2. Give a brief example of when to use ID ( #id ) and when to use classes ( .class ) in CSS.
@ -12,7 +12,7 @@
RGBA is an acronym meaning "Red, Green, Blue, Alpha" where the three first represent subpixel brightness values and the fourth represents opacity. With the RGB colors, you can express most colors that anyone can think of on the top of their head. Usually, we express them with a bitdepth of 8, meaning you can specify each individual color value to a range of 2^8 values -> between 0 and 255. With the alpha channel added, we can also specify how transparent the color should be. This is especially useful for things like non-square icons, watermarks and in web development - see-through floating windows. An example of a color that could be expressed with RGBA would be a 50% seethrough yellow, RGB(255,255,0, 127), or with alternative hexadecimal syntax -> #FFFF007f.
Note that the actual amount of colors you can express with RGBA depends on several other factors like your monitor, the colorspace, the brightness in the room you're sitting
Note that the actual amount of colors you can express with RGBA depends on several other factors like your monitor, the colorspace, the brightness in the room you're sitting.
![Diagram showing hue along the x axis and opacity along the y axis](https://upload.wikimedia.org/wikipedia/commons/0/0b/RGBA_comp.png)
@ -22,7 +22,17 @@
## 5. What CSS selector matches all the p elements inside the article element in the following HTML?
Here, we have two options. One could either do
```HTML
<p>This should not match.</p>
<article>
<h2>This should not match</h2>
<p>This should match.</p>
<p>This should also match.</p>
<p>Do not forget about this one!</p>
</article>
```
Here, we have two options. You could either do
```CSS
article p {}
@ -30,10 +40,10 @@
which specifies all `<p>` elements inside the `<article>`.
The other options would be
The other option would be
```CSS
article > p {}
```
which would only specify `<p>` elements directly beneath the `<article>`. But since there are no `<p>` subchildren, both will work.
which would only specify `<p>` elements directly beneath the `<article>`. But since `<article>` has no `<p>` subchildren, both will work.