CSS Flashcards
What are the names of the individual pieces of a CSS rule?
Selectors - indicate which element the rule applies to.
The same rule can apply to more than one element if you separate the element names with commas.
Declarations
Indicate how the elements referred to in the selector should be styles.
Declarations are split into two parts (a property and a value), and are separated by a colon
Property and value
In CSS, how do you select elements by their class attribute?
Use a dot .class Use class for CSS
In CSS, how do you select elements by their type?
Using a css selector
Matches elements name / write name of element
In CSS, how do you select an element by its id attribute?
#id Hashtag and name of ID
Name three different types of values you can use to specify colors in CSS.
These express color in terms of how much red, green, and blue are used to make it up.
rgb(100,100,0)
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.
#ee3e80
Color name
There are 147 predefined color names that are recognized by browsers.
DarkCyan
What CSS properties make up the box model?
Border - Every box has a border. The border separates the edge if one box from another
Margin - Margins sit outside the edge of the border. You can set the width of a margin to create a gap between the borders of two adjacent boxes.
Padding - is the space between the border of a box and any content contained within it. Adding padding can increase the readability of its content
Content: The area where your content is displayed, which can be sized using properties like width and height.
Which CSS property pushes boxes away from each other?
Margin
Which CSS property add space between a box’s content and its border?
Padding
What is a pseudo-class?
A class applied by the browser when the element is in a selected states
What are CSS pseudo-classes useful for?
It is useful for changing appearances of elements based on interaction
Name two types of units that can be used to adjust font-size in CSS.
Pixels - pixels are commonly used because they allow web designers very precise control over how much space their text takes up.
The number of pixels is followed by the letters px.
Percentages - takes percentage of the default size of text or percentage or parent size of text
Ems - equivalent to the width of the letter m
Most common are pixel, em and rem
What CSS property controls the font used for the text inside an element?
font-family
What is the default flex-direction of a flex container?
the default flex-direction of a flex container is row (left to right)
What is the default flex-wrap of a flex container?
No wrap - try to fit in one row
Why do two div elements “vertically stack” on one another by default?
Div elements are block and create a new line
What is the default flex-direction of an element with display: flex?
Row. left to right
What is the default value for the position property of HTML elements?
static
How does setting position: relative on an element affect document flow?
This does not affect the position of surrounding elements, they stay in the position they would be in normal flow
How does setting position: relative on an element affect where it appears on the page?
It moves the element from the position it would have been during normal flow.
How does setting position: absolute on an element affect document flow?
It comes out of the document flow. (Removed out of document flow entirely.)
Other elements take its place
Acts like its not even there
How does setting position: absolute on an element affect where it appears on the page?
Positions the element in relation to its containing element.
It takes it out of normal flow
Elements move as users scroll up and down in the page
How do you constrain an absolutely positioned element to a containing block?
Set the direct parent to position: relative
What are the four components of “the Cascade”.
Source order - in situations where a property has been declared for an element only once, this is a very straight forward process.
Source order is, simply put, the order that your CSS rules are written in your stylesheet. The styling provided for an element last in your stylesheet is the styling that will ultimately take effect.
Inheritance is the process by which certain CSS properties on a child HTML element can receive value from a parent element, if no CSS for that property is directly declared on the child element.
Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Specificity is based on the matching rules which are composed of different sorts of CSS selectors.
determined by the number of each selector type in the matching selector. When multiple declarations have equal specificity, the last declaration found in the CSS is applied to the element.
!important - gives it the highest priority
What does the term “source order” mean with respect to CSS?
The order in which a rule is written
The further down you get in your stylesheet the more important