CSS Flashcards
What are the names of the individual pieces of a CSS rule?
A selector which points to the html element to be styled –followed by a declaration block within curly braces.
The declaration block contains declarations consisting of properties and values, and are separated from one another with semicolons.
p {
font-family: sans-serif;
color: orange;
}
(Semicolons are not required after the last declaration, but it is good practice nonetheless.)
In CSS, how do you select elements by theirclassattribute?
A period followed by the class name.
.note {
color: red;
}
In CSS, how do you select elements by their type?
Simply state the element name.
h1 {
font-size: 20px;
}
In CSS, how do you select an element by itsidattribute?
The pound key followed by the id name.
#introduction { color: blue; }
Name three different types of values you can use to specify colors in CSS.
color names/keywords
color: purple;
HEX codes
color: #rrggbb;
RGB values
color: rgb(180, 180, 180);
(RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color.)
color: rgba(255, 99, 71, 0.5);
What CSS properties make up the box model?
Border, margin, and padding.
Content is not a property of the box model, but it is still a piece of the entire box model.
Which CSS property pushes boxes away from each other?
Margin
Which CSS property adds space between a box’s content and its border?
Padding
What is box-sizing: border-box ?
border-boxtells the browser to account for any border and padding in the values you specify for an element’s width and height.
If you set an element’s width to 100 pixels, that 100 pixels will include any border or padding you added, and the content box will shrink to absorb that extra width. This typically makes it much easier to size elements.
box-sizing: border-boxis the default styling that browsers use for thetable,select, andbuttonelements, and forinputelements whose type isradio,checkbox,reset,button,submit,color, orsearch.
What is a pseudo-class?
Pseudo-classes allow you to change the appearance of elements when a user is interacting with them.
What are CSS pseudo-classes useful for?
They are useful for visual representation to a user with interacting with a page, such as the color of a button changing color when their mouse is hovering over it, or a link changing colors after a user has clicked on it, so they can see which link they have already visited..
Name at least two units of type size in CSS.
Pixels
Percentages
Em
Rem
Recommendation is to stick to rem over em
Em and rem are similar but work slightly differently
Em is the width of letter m
1 em is default font size
Rem stands for root em
default font size is 16px
so 2rem would be 32px
Rems maintain ratio, only need to change html font to affect everything else
Ems do not maintain ratio
What CSS property controls the font used for the text inside an element?
Font-family
What is the defaultflex-directionof aflexcontainer?
row
What is the defaultflex-wrapof aflexcontainer?
nowrap