CSS Flashcards

1
Q

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

A

Selectors and Declarations

Property and 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

You put a period . in front of the class attribute value

.class-name

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 put whatever element type is followed by curly braces

p {} h1 {} h2 {} div {} em {} span {}

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

id-name

You put a pound symbol # in front of the id attribute value

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, Hex Codes, 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

border, margin, and 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 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

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

Pseudo-classes only apply when the element is in a certain state

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

Webpage interaction

Pseudo-classes allow us to write less code

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

Name at least two units of type size in CSS.

A

Em, pixels, and percentages

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

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

The default direction is row - from 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

No-wrap is the default which makes all the items try to fit on one line

Wrap allows the content to be displayed on multiple lines from top to bottom

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 elements so they begin on a new line

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

Rows, from left to right

17
Q

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

A

Static - No difference from the normal flow

18
Q

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

A

It does not. Other elements stay in the position they would be in normal flow

19
Q

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

A

You can move the element top, right, bottom, or left of its original position

20
Q

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

A

It places the element in relation to its containing element. Absolute positioned elements will MOVE as you scroll on the page.

It no longer has a place in the document flow.

When it is positioned to absolute, it needs to be positioned to it’s parent element or class. It cannot be a static positioning.

21
Q

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

A

It positions itself relative to the parent element or class, as long as the parent element or class is not static.

22
Q

What are the four box offset properties?

A

Top, bottom, left, and right

23
Q

What are the four components of “the Cascade” (What gets prioritized)?

A

Source Order, Specificity, Inheritance, !important

24
Q

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

A

Whichever class or element comes last in the stylesheet will be the rule that is applied

25
Q

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

A

Inheritance - Children elements inherit the parent elements css rule.

26
Q

List three selector type in order of increasing specificity.

A

Type Selectors > Class Selectors > ID Selectors (Weakest to strongest specificity)

27
Q

Why is using !important considered bad practice?

A

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

28
Q

What does the transform property do?

A

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

29
Q

Give four examples of CSS transform functions.

A

rotate, scale, skew, translate

30
Q

The transition property is shorthand for which four CSS properties?

A

Delay, Duration, Property, Timing-Function

31
Q

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

A

display mode, forced colors, height, hover, screen, print

32
Q

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

A

meta name=”viewport”

content=”width=device-width, initial-scale=1”

33
Q

What is a breakpoint in responsive web design?

A

A breakpoint is the point at which a media query is introduced.

It’s where you want to snap your layout to a different set of proportions.

34
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

This allows you to adjust the size of the elements in comparison to the size of the browser or viewport instead of a static/hard coded pixel size

This influences a ‘fluid’ design rather than ‘static’ design

35
Q

If you introduce CSS rules for a smaller min-width after the style 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.