Aloysious' Codefellows Reading Notes
CSS / RGB / HSL / Hex codes / Layout / Rule / Selector / Property & value / Curly braces
:electron: CSS MASTER CHEAT
:mortar_board: Beginner’s guide to CSS
A CSS rule-set consists of a selector and a declaration block:
The selector points to the HTML element you want to style.
The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a CSS property name and a value, separated by a colon.
Multiple CSS declarations are separated with semicolons, and declaration blocks are surrounded by curly braces.
There are three ways of inserting a style sheet:
All the styles in a page will “cascade” into a new “virtual” style sheet by the following rules, where number one has the highest priority:
So, an inline style has the highest priority, and will override external and internal styles and browser defaults.
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element is unique within a page, so the id selector is used to select one unique element!
To select an element with a specific id, write a hash (#) character, followed by the id of the element.
The CSS rule below will be applied to the HTML element with id=”para1”:
#para1 { text-align: center; color: red; }
The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the class name.
In this example all HTML elements with class=”center” will be red and center-aligned:
.center { text-align: center; color: red; }
You can also specify that only specific HTML elements should be affected by a class.
In this example only <p> elements with class=”center” will be center-aligned:
p.center { text-align: center; color: red; }
The universal selector (*) selects all HTML elements on the page.
UNIVERSAL BORDERS
*{ border: solid: black; 1px }
The grouping selector selects all the HTML elements with the same style definitions.
h1, h2, p { text-align: center; color: red; }
< HEAD >< TITLE >Your text< /HEAD >< /TITLE >.
The correct order is:
< HEAD >< TITLE >Your text< /TITLE >< /HEAD >.
The opacity property specifies the opacity/transparency of an element. It can take a value from 0.0 - 1.0. The lower value, the more transparent.
Term | Context |
---|---|
CSS | Cascading Style Sheets allows you to create rules that specify how the content of an element should appear It reads from top to bottom |
RGB | rgb(red, green, blue) These express colors in terms of how much res, green and blue are used to make it up. for example Rgb (100.100.90) Each parameter (red, green, and blue) defines the intensity of the color between 0 and 255. |
HSL | Hue, Saturation, Lightness:Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. Saturation is a percentage value, 0% means a shade of gray, and 100% is the full color. Lightness is also a percentage, 0% is black, 50% is neither light or dark, 100% is white |
HSLA Value | hsla(hue, saturation, lightness, alpha) The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all): |
Hex codes | These are six-digit codes that represent the amount of red, green and blue in a color, preceded by a pound or hash # sign. For example: #ee3e80In CSS, a color can be specified using a hexadecimal value in the form: #rrggbb Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00 and ff (same as decimal 0-255). |
Layout | how div elements appear / sections of the page all together make the layout of a web page |
Rule | opening and closing brackets is an example of rules they need to be performed in the right order to work as well |
Selector | indicate which element the rule applies to. The same rule can apply to more than one element if you seperate the element names with commas. |
Declarations | indicate how the elements referred to in the selector should be styled. Declarations are split into two parts (a proprty and a value), and are sepatated by a colon. |
Properties | indicate the aspects of the element you want to change. For example, color, font, width, height and border. |
Values | specify the settings you want to use for the chosen properties. For example, if you want to specify a color property then the value is the color you want the text in these elements to be. |
Curly braces | Curly braces { } are special syntax in JSX. It is used to evaluate a JavaScript expression during compilation. A JavaScript expression can be a variable, function, an object, or any code that resolves into a value. |
Comments | Comments are used to explain the code, and may help when you edit the source code at a later date.Comments are ignored by browsers. |
Colors | Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values. |
Skim
Read