CSS Flashcards

(41 cards)

1
Q

What are the names of the individual pieces of a CSS rule?

A

selector, declaration, curly brace, property, value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you select elements by their class attribute?

A

by adding a period in front:
.example {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you select elements by their tag name?

A

just add the tag name
example {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you select an element by its id attribute?

A

by adding a # in front:
#example {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name three different types of values you can use to specify colors in CSS.

A

the color name, rgb values, hexcodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What CSS properties make up the box model?

A

border, margin, padding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which CSS property pushes boxes away from each other?

A

Margin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which CSS property add space between a box’s content and its border?

A

Padding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a pseudo-class?

A

pseudo-classes are keywords added next the the selector that specifies a special state of the selected element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Give an example of a pseudo-class

A

button : hover {
background-color: blue;
}
this would change the color of the button if your cursor hovers over it.
:hover :active :focus are a few other ones

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are CSS pseudo-classes useful for?

A

it helps change an element when a specific action is taken

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the :nth-child() pseudo class do?

A

an :nth-child() pseudo-class is used to specify between a group of siblings using their positions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Name the types of units that can be used to adjust font-size in CSS.

A

pixels(px), percentages, and ems(em)/rem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What CSS property controls the font used for the text inside an element?

A

font-family

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the default flex-direction of a flex container?

A

row

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the default flex-wrap of a flex container?

A

nowrap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Why do two div elements “vertically stack” on one another by default?

A

because they are block level elements so each div would separate from each other

18
Q

What is the default flex-direction of an element with display: flex?

19
Q

What are the three primary components of a page layout? (Which helper classes do you need?)

A

container, row, columns

flexbox

20
Q

What is the minimum number of columns that you should put in a row?

21
Q

What is the purpose of a container?

A

To hold the contents needed for the layout

22
Q

What is the default value for the position property of HTML elements?

A

position: static;

23
Q

How does setting position: relative on an element affect document flow?

A

doesn’t really change the flow of the document but it moves the element

24
Q

How does setting position: relative on an element affect where it appears on the page?

A

it moves an element in relation to where it would’ve been

25
How does setting position: absolute on an element affect document flow?
it changes the flow as the absolute value allows the element to move outside of the box or container
26
How does setting position: absolute on an element affect where it appears on the page?
it can be out of the box/container this means it won't affect the position of the other elements
27
How do you constrain an absolutely positioned element to a containing block?
add the position: relative to the parent element
28
What are the four box offset properties?
top, right, bottom, left
29
What are the four components of "the Cascade".
source-order, inheritance, specificity, !important
30
What does the term "source order" mean with respect to CSS?
the latest or most recent one in order of the css rule sets
31
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
because child elements inherit the styling of their parent element
32
List the three selector types in order of decreasing specificity.
id, class, type
33
Why is using !important considered bad practice?
us as last resort, it overrides everything, it will be hard to change the element with it, therefore making it hard for team projects//collaborations
34
What does the transform property do?
it transforms the element, either it changes its form, direction, etc.
35
Give four examples of CSS transform functions.
rotate, scale, translate, skew
36
The transition property is shorthand for which four CSS properties?
transition-property , transition-duration , transition-timing-function , and transition-delay
37
Give two examples of media features that you can query in an @media rule.
min-width, max-height, resolution, aspect-ratio
38
Which HTML meta tag is used in mobile-responsive web pages?
the viewport meta tag
39
What is a breakpoint in responsive Web design?
it's a point where the change of the style happens
40
What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a "column" class in a responsive layout?
for smaller devices like phones it will scale the width by percentage instead of a set px since the px set is probably too big for the phones (tldr. good and efficient for smaller devices)
41
If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will "win". Why is that?
because of the source order. whichever is last on the order "wins" only time the source order rule is overpowered is when the specificity is higher/stronger id/class/tag