CSS Flashcards

1
Q

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

A

p {
font-family: Arial;
}

p = selector
font-family: Arial; = declaration
font-family: = property
Arial = 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

.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

p { }

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{ }

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

Margin
Border
Padding
Content

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?

A

A way to select an element when its in a given state
Exp: being hovered
Currently being clicked on

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

They let you apply different styling to elements when those elements are in their given states

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

px
rem
em

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

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 (everything goes in one line)

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

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

A

Every element is status by default

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

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

A

It’ll transform the item from its original position while still holding its original space on the file

17
Q

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

A

It’ll appear on the same place until transformations are added

18
Q

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

A

The surrounding elements act as if the moved item was never there to begin with.

19
Q

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

A

It’ll look for the first ancestor who is not set to position: static; (all by default)

20
Q

What are the four box offset properties?

A

top
Bottom
Left
right

21
Q

What are the four components of “the Cascade”.

A

Source Order
Inheritance
Specificity
!important

22
Q

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

A

If two different selectors are on the same specificity, the selector which is written lowest on your styles.css sheet will be applied to your HTML page.

23
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

By default, many styles affect the specified element and all children under it, through inheritance.

24
Q

List the three selector types in order of increasing specificity.

A

Element
Class
ID

25
Q

Why is using !important considered bad practice?

A

It breaks the natural cascading in your code so it would make debugging difficult.

26
Q

What does the transform property do?

A

It allows you to take an element on your HTML page, and move it around, from its original position, with CSS

27
Q

Give four examples of CSS transform functions.

A

transform: rotate(-50deg);
transform: translateY(0.25rem);
transform: translateX(0.25rem);
transform: scale(x%, y%);

28
Q

The transition property is shorthand for which four CSS properties?

A

Its a single combination of transition-property, transition-duration, transition-timing-function, & transition-delay

29
Q

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

A

Only screen
Only print

@media only screen and (min-width: 500px) { css codeblock }

30
Q

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

A

Viewport meta tag

31
Q

What is a breakpoint in responsive Web design?

What does it look like?

A

A given width of the screen where it would trigger different behaviors of styling to take place

@media only screen and (min-width: 500px) {
    img {
        width: 50%;
    }
}
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

Percentages are based on the ever-changing size of the screen, so they adjust with the screen size.

Pixels are stuck to a certain size, no matter how large the screen. This would lead to items being too large for small screens or too small for large screens.

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

The CSS follows the Source Order rule. The lowest item on the styles sheet takes precedence.