CSS Flashcards

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?

A

row

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?

A

one

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
Q

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

A

it changes the flow as the absolute value allows the element to move outside of the box or container

26
Q

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

A

it can be out of the box/container this means it won’t affect the position of the other elements

27
Q

How do you constrain an absolutely positioned element to a containing block?

A

add the position: relative to the parent element

28
Q

What are the four box offset properties?

A

top, right, bottom, left

29
Q

What are the four components of “the Cascade”.

A

source-order, inheritance, specificity, !important

30
Q

What does the term “source order” mean with respect to CSS?

A

the latest or most recent one in order of the css rule sets

31
Q

How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?

A

because child elements inherit the styling of their parent element

32
Q

List the three selector types in order of decreasing specificity.

A

id, class, type

33
Q

Why is using !important considered bad practice?

A

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
Q

What does the transform property do?

A

it transforms the element, either it changes its form, direction, etc.

35
Q

Give four examples of CSS transform functions.

A

rotate, scale, translate, skew

36
Q

The transition property is shorthand for which four CSS properties?

A

transition-property , transition-duration , transition-timing-function , and transition-delay

37
Q

Give two examples of media features that you can query in an @media rule.

A

min-width, max-height, resolution, aspect-ratio

38
Q

Which HTML meta tag is used in mobile-responsive web pages?

A

the viewport meta tag

39
Q

What is a breakpoint in responsive Web design?

A

it’s a point where the change of the style happens

40
Q

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?

A

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
Q

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?

A

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