CSS Flashcards

1
Q

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

A

Start of a new CSS rule set:
[selector] { start of declaration block
property : value ;
} end of 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

To select an element by their class attribute you preface the class name with a .

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

To select an element by its tag name you just use the tag name as the selector

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

To select an element by their id attribute you preface the id name with a #

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

Color Name - e.g. White, Black, Blue

Hex Code - e.g. #ffffff

RGB Value - e.g. rgb(255 255 255);

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

The content (length and width)
Padding (space between content and border)
Border
Margin (space between border and other boxes)

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

The margin property

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

The padding property

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

What is a pseudo-class?

A

A pseudo class is a keyword added to selector that specifies a special state of the selected element. Pseudo-classes let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors e.g. :hover (when element is hovered) :active (when the element is in use such as a click)

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

CSS pseudo-classes are useful for providing feedback to the user (e.g. form elements [buttons active/inactive states] or hyperlinks [visited or not])

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 (px), Ems (em), 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 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

The default flex-direction of a flex container is row

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

The default flex-wrap of a flex container is no-wrap

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

Divs are block elements which do not allow any other elements to be on the same line as them.

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

The default flex-direction is row.

17
Q

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

A

The default value for position is static.

18
Q

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

A

The document flow stays the same as the element still takes up the space it would normally occupy.

19
Q

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

A

The element moves based on where it was supposed to be.

20
Q

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

A

Position absolute removes an element from normal document flow.

21
Q

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

A

The element will appear where it would normally but it may overlap or be overlapped by any elements that will go to occupy its space when it was removed from document flow.

22
Q

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

A

You set the containing block to position relative.

23
Q

What are the four box offset properties

A

Top, right, bottom, left

24
Q

What are the four components of “the Cascade”.

A

Source Order, Specificity, Inheritance, !Importance

25
Q

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

A

Source Order is the order the code is listed in the css file. The most recently added code is what is applied (the code lower on the css file)

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 will apply a style of an element to its children if there is no additional CSS rule for the same style added to the child

27
Q

List the three selector types in order of increasing specificity.

A

Type - Class - ID

28
Q

Why is using !important considered bad practice?

A

!important reverses the cascade order for style sheets. It forces a styling to an element.

29
Q

What does the transform property do?

A

It allows you to move elements along the x, y, and z axes. You can rotate, skew, angle… elements

30
Q

Give four examples of CSS transform functions.

A

rotate - spins an image clockwise (negative value for counter clockwise)
translate - moves an image horizontally and vertically
scale - resizes an image on a 2D plane (can also flatten/stretch images)
skew - resizes/shapes an element on a diagonal plane
matrix -

31
Q

The transition property is shorthand for which four CSS properties?

A

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

32
Q

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

A

Width, min-width, height, orientation

33
Q

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

A

The viewport meta tag

34
Q

What is a breakpoint in responsive Web design?

A

A breakpoint is a spot where the web page should change its styling. Often this is used for styling for different sized screens (mobile, tablet, or desktop)

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 % allows the content to scale with the size of the page

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

Because of CSS cascade (source order) the “newest” ruleset (closest to the bottom) will be applied over previous rules