CSS Flashcards

1
Q

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

A
  • Selector

- Declaration (comprised of a property and its 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

With the class selector

Ex. .note { } - targets any elements whose class attribute is note

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

You select the elements with their name and { }

Ex. h1 { } - this will select all h1 elements

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

With the id selector #

Ex. #introduction - targets the element whose id attribute has the value of introduction

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 value (red, green, blue)
    • Values are expressed between 0 and 255
    • Ex. rgb (102, 205, 170)
  • hex codes
    • has 6 characters
    • Ex. #66cdaa

-color names

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, padding, border, width, height

*Width & height = content of box

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 adds 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

Keywords added to a selector that specifies a special state of the selected elements

Ex. “ : hover “ can be used to change a button’s color when the user’s pointer hovers over it

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

It is useful for applying styling to an element that is not only in relation to the content but also in relation to external factors (also good for visual and interactive purposes)

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

Pixels, percentages, ems

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-family property

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

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

A

Nowrap (all flex items will be on one line)

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

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

A

They are block-line elements and block line elements start on new lines

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

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

A

Row (left to right)

17
Q

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

A

Position: static (block-level elements sit on top of each other)

18
Q

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

A

It’ll still remain in flow with the document just like static properties but the only difference is that now its positioned elsewhere

19
Q

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

A

It’s still in the same in the position on the page, it is just offsetted if an offset property is set

20
Q

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

A

It no longers exist on the document flow

21
Q

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

A

Its positioned next to the closest non static position value

22
Q

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

A

With any properties that isn’t static (absolute or relative)

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
  • !important
25
Q

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

A

The order that your CSS rules are written in your stylesheet; the styling provided for an element that is last in the styling sheet is the one that takes effect (bottom styling is stronger)

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

It is possible because of inheritance; this process allows child HTML elements to receive value from a parent element if no css for that property [the child] is declared

27
Q

List the three selector types in order of increasing specificity.

A
  • Type selectors (e.g., h1) and pseudo-elements (e.g., ::before).
  • Class selectors (e.g., .example), attributes selectors (e.g., [type=”radio”]) and pseudo-classes (e.g., :hover).
  • ID selectors (e.g., #example)
28
Q

Why is using !important considered bad practice?

A

It makes debugging more difficult by breaking the natural cascading in your style sheets

29
Q

What does the transform property do?

A

Lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.

30
Q

Give four examples of CSS transform functions.

A

Matrix
Translate
Scale
Rotate

31
Q

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

A

Update, width, height, hover, etc.

32
Q

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

A

Viewport meta tag

33
Q

The transition property is shorthand for which four CSS properties?

A

Transition-property: sets the CSS properties to which a transition effect should be applied.

Transition-duration: sets the length of time a transition animation should take to complete. By default, the value is 0s, meaning that no animation will occur.

Transition-timing-function: sets how intermediate values are calculated for CSS properties being affected by a transition effect.

Transition-delay: specifies the duration to wait before starting a property’s transition effect when its value changes.

34
Q

What is a breakpoint in responsive Web design?

A

When certain styles are being applied based on media queries
-Especially device width

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

Using a percentage allows the browser page to be responsive with different devices; if we use a pixel, the size is fixed and it will remain that size regardless of the device

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

The smaller width will win if it is placed last due to the ordering rule of CSS (cascading) - things that are placed last get priority