From 700f1d97018c7340912218efb27fb37de6a6f4cf Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 2 Sep 2020 15:07:56 +0200 Subject: [PATCH] Answer questions --- questions.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 questions.md diff --git a/questions.md b/questions.md new file mode 100644 index 0000000..c37763b --- /dev/null +++ b/questions.md @@ -0,0 +1,29 @@ +# Questions + +## 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. + +## 2. Give a brief example of when to use ID ( #id ) and when to use classes ( .class ) in CSS. + + ID is used when there's a piece that only occurs once on the page. A class is used for common parts that will occur several times. Let's take youtube as an example. The search bar, the logo in the header and the video is something that will only occur once. Those are good opportunities to use IDs. Comments and suggested videos however, will show up multiple times. Using classes is a good way to reach these pieces with JS and CSS. Sometimes, people confuse tags with classes. Tags are used in the same way as classes to mark several elements of the same type. But it is good practise to only use the standard HTML tags defined by WHATWG and use classes for any custom recurring parts that you have defined yourself. It makes it easier to define objects with several classes at once, and it's what's expected by most browsers (even though most browsers are able to handle custom tags too.) + +## 3. What does RGBA mean and what colors can you express with it? + + 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 + + ![Diagram showing hue along the x axis and opacity along the y axis](https://upload.wikimedia.org/wikipedia/commons/0/0b/RGBA_comp.png) + +## 4. Why do we include CSS files inside the head element and not inside the body element? + + We include the CSS into the head element in order to separate content and settings/metadata. Information like styling, scripts, and metadata should not be mixed with the content, and is therefore specified in the `` before the `` + +## 5. What CSS selector matches all the p elements inside the article element in the following HTML? + + ```HTML + article p {} + ``` + + This specifies all `

` elements inside the `

`, in contrast to `article > p {}` which would only specify `

` elements directly beneath the `

`.