CSS Flashcards

1
Q

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

A

A CSS rule is made up of a Selector, Property, and Value (property and value stored in key-value pairs within the declaration block)

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

denoted with a period

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 tag name?

A

elementname

example:

h1 {
     font-size: 24px;
}
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

denoted with a hashtage (#)

example:

#language {
     color: red;
}
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 set color in CSS

A

Keywords (Color name)
Hex Codes
RGB
RGBA
HSL
HSLA

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

Margin, Border, Padding, Height, Width

refers to how HTML elements are modeled in browser engines and how the dimensions of those HTML elements are derived from CSS properties

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 and what is it useful for?

A

a selector that specifies a special state of the selected element(s)
a class that cannot be forced but must be achieved with a special state (ex. user interaction)

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

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

A

em, ch, ex, cm, rem

preferred: rem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
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
12
Q

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

A

row (left-to-right)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
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
14
Q

What are the three primary components of a page layout?

A

Container, Row, and Column

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

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

A

At least one, even if that column takes up the full space

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

What is the purpose of a container?

A

It helps with grouping together the components within a page to make layout control easier.

17
Q

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

A

static

18
Q

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

A

The element is positioned according to the normal flow of the document, and then offset relative to itself based on the box offset properties

19
Q

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

A

The offset does not affect the position of any other elements in the document flow.

20
Q

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

A

Absolutely positioned elements are removed entirely from the document flow

21
Q

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

A

the element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to its closest positioned ancestor, if any; otherwise, it is placed relative to the initial containing block.

22
Q

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

A

Define each offset property to define the boundary within the containing block

23
Q

What are the four box offset properties?

A

top, bottom, left, right

24
Q

What are the four components of “the Cascade”

A

Source Order, Inheritance, Specificity, and Important

25
Q

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

A

The order in which the rules are written, with rules written towards the bottom over-writing those on top.

26
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

Inheritance (set desired property to inherit from parent and apply style to parent if its not a property with inherit as a default)

27
Q

List the three selector types in order of increasing specificity.

A

No value > Element Type > Class > ID

28
Q

Why is using !important considered bad practice?

A

Since it overrides everything it would be difficult to debug, as well as defeat the purpose of the other three components of the Cascade. If rules are written respecting source order, inheritance, and specificity there should be no need to use !important.

29
Q

The transition property is shorthand for which four CSS properties?

A

transition-property -selects property to apply transition
transition-duration -sets duration of transition effect
transition-timing-function -sets acceleration curve of effect
transition-delay -sets delay before transition begins (can be negative)

30
Q

What does the transform property do?

A

It allows you to rotate, scale, skew, or translate an element.

31
Q

Give four examples of CSS transform functions.

A
rotate();
translate();
skew();
scale();

note that many are shorthands for function-axis such as rotateX() or translateY()

32
Q

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

33
Q

What is the affect of setting an element to display: none?

A

The element is not displayed and removed from the document flow.

34
Q

What is a breakpoint in responsive Web design?

A

It is a point in which content starts to “break” from the viewport sizing.

35
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

If it uses a percentage content will scale with viewport size instead of always being a set unit’s size.

36
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

This is due to source order, with things at the bottom of the stylesheet taking more importance than those above it.