CSS Flashcards

1
Q

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

A

css declarations:
selector { declaration }
declaration consists of {property: value}

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

In CSS, how do you select elements by their class attribute?

A

.classname { }

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

In CSS, how do you select elements by their type?

A

elementname { ]

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

In CSS, how do you select an element by its id attribute?

A

idname { }

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

rgb values
ex: rgb (200, 200,200)

hex codes
ex: #ee3e80

colors names
ex: white

hsl
ex: hsl(hue, saturation, lightness)

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
  • Content
  • Padding: distance between inside content and border
  • Border
  • Margin: space between border and outside edge of the element
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

What is a pseudo-class?

A

a keyword added to a selector that specifies a special state of the selected element(s)

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

What are CSS pseudo-classes useful for?

A

allows us to apply style to an element in relation to external factors, like the history of the navigator (:visited), the status of its content(:, or position of the mouse (:hover)

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

What are CSS pseudo-classes useful for?

A

allows us to apply style to an element in relation to external factors, like the history of the navigator (:visited), the status of its content, or position of the mouse (:hover)

extended functionality

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

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

A

px - pixels
% - percentages
em - width of a letter m

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

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

A

font or font-family

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

What are the four components of “the Cascade”.

A

source order
inheritance
specificity
important

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

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

A

prioritizing the bottom properties, as styles.css is read from top to bottom

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

Why is using !important considered bad practice?

A

you can end up in a weird place where everything is important, so nothing is important. it just gets too confusing

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

List the three selector types in order of increasing specificity.

A

tag
class
id

17
Q

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

A

row

18
Q

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

A

nowrap

19
Q

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

A

because div elements are block elements

20
Q

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

A

row

21
Q

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

A

position static

normal flow - every block-level element appears on a new line

22
Q

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

A

does not affect the position of surrounding elements; they treat like it is where it would normally be

23
Q

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

A

moves an element from the position it would be in normal flow, shifting it to the top, right, bottom, or left of where it would have been placed

24
Q

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

A

it does not affect the position
of any surrounding elements (as they simply ignore the space it would have taken up)

will always cause other elements around it to move, since they no longer treat it like it exists

25
Q

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

A

it stays where you set it to and moves as users scroll up and down on a page.

26
Q

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

A

set the parent container to absolute: relative

or any non-static properties

27
Q

What are the four box offset properties?

A

top
bottom
left
right

28
Q

The transition property is shorthand for which four CSS properties?

A

transition-property: sets any CSS property (ex: background-color to which the effect is applied

transition-duration: how long it’ll take to complete transition // by default it’s 0, so always make sure to set something

transition-timing-function: speed of the function

transition-delay: how to long wait before a transition begins

29
Q

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

A

color
width
height

30
Q

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

A

super important. if you don’t use this, it will be using “virtual viewport” (old school)

31
Q

What is a breakpoint in responsive Web design?

A

points at which a media query is introduced (adjusting for changes in screen size)

mobile first responsive design - working with a smaller width first and adding @media as the screen grows larger (best practice)

32
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

it will keep adjusting to the screen size as it changes

33
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

source order - css rules are read from top to bottom, so last one will take priority