Coursera CSS Basics Flashcards
What is the selector
Tag {
}
Declaration Block
holds information about the properties and values you are going to add to the selector.
Property and Value
Property says what we are changing and Value is what we are changing it to.
Example
h1{
color(property): blue(value);
background-color(property): grey(value);
}
How do you link to a CSS file?
<link></link>
Element Selectors
When you use an element selector, the CSS rule will apply to all elements on the webpage.
ID Selectors
use the ID Attribute of an HTML element. the ID is unique within the webpage and prefixed with a # character.
Example:
HTML
<span>New!</span>
CSS
#latest {
background-color: purple;
}
Class Selectors
Elements can be selected based on the class attribute applied to them. Can be applied to multiple elements.
HTML
<a>Go Back</a>
<p>Go Forward</p>
CSS
.navigation {
margin: 2px;
}
Name 5 main ways to reference color.
- RGB Value
- RGBA Value
- HSL Value
- Hex Value
- Predefined color names
RGB Value
RGB is a color model that adds the colors red (R), green (G) and blue (B) together to create colors. This is based on how the human eye sees colors.
Each value is defined as a number between 0 and 255, representing the intensity of that color.
For example, the color red would have the RGB value of 255,0,0 since the intensity of the red color would be 100% while blue and green would be 0%.
The color black then would be 0,0,0 and the color white 255,255,255.
p {
color: rgb(255, 0, 0);
}
RGBA Value
RGBA is an extension of RGB that add an alpha (A) channel. The alpha channel represents the opacity, or transparency, of the color.
HSL
HSL is a newer color model defined as Hue (H), Saturation (S) and Lightness (L). The aim of the model is to simplify mental visualization of the color that the value represents.
Hex value
Decimal is what you use every day. Digits range from 0 to 9 before tens and hundreds are used.
Hexadecimal is similar, except it has 16 digits. This is counted as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Predefined color names
Modern web browsers support 140 predefined color names. These color names are for convenience purposes and can be mapped to equivalent hex/RGB/HSL values.
Code for changing font
font-family: font name1, font name2;
How to set font size
font-size: #px;
Change all elements to uppercase.
text-transform: uppercase;
Text Decoration is used for what.
text-decoration: exmample;
Underlining and strike-through.
p {
text-decoration-line: underline;
text-decoration-color: red;
text-decoration-style: solid;
text-decoration-thickness: 5px;
}
Box Model
-Content
-padding
-border
-margin
Document-Flow
How the computer calculates the position of HTML elements.
Block level elements
A block level element will occupy the full horizontal width of its parent element and the vertical height of its content.
Inline Elements
In line elements only occupy the width and height of their content. They don’t appear on a new line, hence the name in line. Therefore, multiple in line elements can form a row of elements.
Text Alignment
Text alignment can be set to left, right, center and justify.
p {
text-align: center;
}