CSS Flashcards

1
Q

What are the names of the individual pieces of a CSS rule? Describe the syntax.

A

Selector / Declaration block made up of Properties / Values

Selector followed by an opening curly brace.
Property, colon, value, semicolon. You can add as many properties and values you want to one rule. End the rule for that selector with the closing curly brace.

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 type?

A

Element-type-name { }

EX: body { } - this selects the body element

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

In CSS, how do you select elements by their class attribute?

A

.note { }

This will select any element whose class attribute has a value of “note”

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

What is a Universal Selector?

A
  • { } - This targets all elements on the page
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In CSS how do you select an element that is a child of another element?

A

li > a { } - This targets any < a > elements that are children of an < li > element (but not other < a > elements in the page and not the < li > element itself)

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

Name 3 different types of values you can use to specify colors in CSS

A

RGB Values (values for red, green, and blue are expressed as numbers between 0 and 255)

Hex Codes (Hex values represent values for red, green, and blue in a hexadecimal code)

Color Names (colors are represented by predefined names, however they are very limited in number)

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

What is a pseudo-class?

A

A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). For example :hover can be used to change a buttons color when the user’s pointer hovers over it.

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

What are CSS pseudo-classes useful for?

A

Pseudo-classes allow you to change the styling/ appearance of elements when a user is interacting with them.

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

Name at least 2 units of type size in CSS

A

Pixels (px), Percentages(%), Ems (em), REM

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

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

A

nowrap - all flex items will be on one line

17
Q

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

A

Because div elements are block elements - so by default they start on a new line

18
Q

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

A

row - left to right

19
Q

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

A

Static = normal flow

20
Q

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

A

Relative Positioning does not affect the document flow. The surrounding elements still observe the relative element as if they were in the same position.

21
Q

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

A

Setting position:relative does not affect where it appears on the page. You must modify the box offset properties to change the positioning on the page.

22
Q

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

A

An element set with Absolute positioning is taken out of normal flow.

The document and surrounding elements to not observe that element exists

23
Q

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

A

Setting position:absolute is now positioned in relation to its containing element.

24
Q

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

A

The parent containing element must not be static. (use relative)

25
Q

What are the four box offset properties?

A

top, right, bottom, left

26
Q

What are the 4 components of “the Cascade”?

A

Source order, specificity, inheritance, ! important

27
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 LAST in your stylesheet is the styling that will ultimately take effect.

28
Q

How is it possible for the styles of an element to be applied to its children as well without and additional CSS rule?

A

By using and inherited property - a property which by default are set to the computed value of the parent element.

29
Q

Why is using ! important considered bad practice?

A

It makes debugging more difficult by breaking the natural cascading in your stylesheets. ! important is very difficult to override.

30
Q

What does the transform property do?

A

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

31
Q

Give four examples of CSS transform functions.

A

translate( ); skew ( );

rotate ( ); scale ( );

32
Q

The transition property is shorthand for which 4 CSS properties?

A

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

33
Q

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

A

width (min or max also) - most common — more on MDN

34
Q

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

A

The Viewport meta tag.

< meta name=”viewport… >

35
Q

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

A

Turns off the display of an element so that it has no effect on layout (the document is rendered as though the element did not exist). All descendant elements also have their display turned off.

36
Q

What is a breakpoint in responsive Web design?

A

The point at which a media query is introduced.

37
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 changes the size relative to the parent/s - which allows for scaleability

38
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

Due to CSS source order - the last rule on the page will take effect and the rule for a larger width will not be read