CSS Basics Flashcards
Where do you write your CSS?
In a separate file
What part of HTML do you link your CSS?
The Head
How to write link tag to link CSS to HTML? Where do you write it?
Write in HTML head
< link rel= “stylesheet” href= “path” >
p{
color: red;
font-weight: bold;
}
What is P?
The selector
p{
color: red;
font-weight: bold;
}
What is:
Color: red;
A declaration (line)
p{
color: red;
font-weight: bold;
}
What is
{
color: red;
font-weight: bold;
}
Declaration Block
What is
p{
color: red;
font-weight: bold;
}
A rule
p{
color: red;
font-weight: bold;
}
What is color?
Property
p{
color: red;
font-weight: bold;
}
What is red?
A value
p{
color: red;
font-weight: bold;
}
What happens if you forget ;?
The stuff after might break/ no render
What is the cascade principle?
Read CSS from top to bottom.
Code below overrides code above
Different parts of CSS have stronger value than others. What is this point system called?
Specificity weight
p{
color: red;
font-weight: bold;
}
p{
color: blue
}
If you want P to be red what can you do? What ex.
Give P a higher specificity weight (ex. Add a class)
4 ways to CSS color?
Word
Hex
RGBa
HSLa
What color property?
0, 100%, 50%, 1
HSLa
Hue, saturation, light
What CSS color property? What does the last number mean?
(255, 0, 0, 1);
RGBa.
Last number = transparency
FF0000
What color property?
Hex
What’s an alpha channel and what property do you find it? What’s the range?
Alpha = the a in RGBa or HSLa = transparency label
Range = .01 -1
How to write CSS font-family? Explain the different parts.
Write link in Head of HTML. Then in CSS…
P{
font-family: ‘sans pro’, ‘helvetica’ sans-serif;
Sans pro = 1st choice
All others = backups
How to link font family to HTML? Where to write it? What does it look like on the CSS side?
In head.
Html = < link href = “ URL of font “ rel = “ stylesheet “ >
CSS = font - family : ‘ font 1 ‘ , ‘ font choice 2 ‘ font choice 3 ;
Where do you get new font links?
Check google fonts
When adding fonts to your HTML, do you put the link before or after your CSS stylesheet link? Why?
Before!
The CSS has instructions for the font. CSS cant load the font, if the font not available
Section
——p
How to make p red?
Section > p{
color: red;
}
> is a parent child selection
Section
>article
»p
What is article to section?
Article = direct descendant of section
2 p’s are nested in a section. What’s their relationship?
Siblings
Section
>article
»P
What is section and article to P?
Section = grandparent Article = Parent
What’s the difference between parent>child and parent child?
Parent > is direct child selection
Parent child = all child’s in a parent
You use P + P selection. Why does only the 2nd P get targeted?
P + P = all the P’s following a P. Initial P doesn’t follow a P
This model talks about how different element takes up space. And how they’re spatially related to each other?
The box model.
4 important parts of box model?
Height/width
Padding
Border
Margin
Every single element in HTML is a _____
Box
If box width = 100px, and box border width = 10px, padding right=20px. how wide is total section?
140px!
Border, margin, content, padding. Which is outermost to inner most?
Margin, border, padding, content
What’s the point of padding?
Creates distance between content and its border.
H2.likesquack.dinosaur{
If the selector has no space, what does that mean?
Means all elements that are H2s WITH likesquack class WITH dinosaur class. No nesting. All simultaneous.
What direction will text go if you float it Left? Right?
All the way up, all the way Left. Right = opposite
How to apply a rule to multiple selectors?
Use commas! (Header,footer{)
How to select a class in CSS (ex. Class=zebra)
.zebra
How to select an ID in CSS (ex = fruit)
fruit
What are the 3 basic selectors in CSS?
1 = type (ex. P, div, H1..) 2= class (.zebra) 3= ID (#animal)
How to link CSS into HTML? What part of HTML do you link CSS?
Link inside head.
link rel=stylesheet href = file location.
What are two CSS resets? How are they different?
Eric Myer’s reset = normal popular variant
Normalize.css = more advanced reset.
How to write a CSS comment?
/* content */
What is the issue with the following CSS selector? Why?
.hotdog p.mustard
Not best practice to preface a class selector w/ an element. Better to select all elements of a given class, not just one type of element. .hotdog .mustard is better.
In a combined selector, which one is the key selector? What are the other parts called?
Key selector = the last selector. All other before it = pre-qualifiers
How many different classes can you assign to an element? Give ex.
Many. Ex. < a class = bean bean-tower > < / a > (2 classes)
What does em mean in CSS? Example?
For length sizing. Em = how many times size of font. Width = 5em;