CSS Flashcards

1
Q

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

A

Selector, declaration block, declaration has property and value, and closing curly brace of the 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

Use a period/dot before the class attribute

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

Just write the tag name, like body, h1, article

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

Use # before the id attribute

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, Hex codes, color names
Ex. rgb(102, 205, 170) hex code (#66cdaa), color name (MediumAquaMarine)

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

Content(width & height), border, margin, 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 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

It’s a class that changes the appearance when the user is interacting with it.
Ex. hovering over a button, cursor changing when hovering, or active (actively clicking and holding down mouse), focus (when browser knows you are ready to interact with the element like when cursor is in a form input ready to accept typing), visited, link, disabled

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 helps distinguish the actions a user can interact with or has already interacted with.
Ex. the link can change colors depending on if it was already visited or if it’s about to be clicked aka hovering.

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

Px, rem(can use quarter sizes, 1.25, 1.5 etc), 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-size, font-family, font-weight, font-style, text-transform, text-decoration

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/horizontal

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.
tries to fit everything into 1 line, which may cause container to overflow.

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

Because they are default block element

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

static

18
Q

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

A

The element moves in relation to where it would have been in normal/static flow, but doesn’t affect document flow since it acts like it takes up the same space.

19
Q

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

A

The element retains its size but it can be moved left or right or top or bottom

20
Q

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

A

The element acts like they don’t exist and removing it from document flow

21
Q

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

A

The properties (left, right, top, bottom) specify where the element should appear in relation to its containing element(edge).

22
Q

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

A

Absolute positioned elements position themselves within the first non-static ancestor they have, so you would have to make the containing block position: 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

If the weight is the same, then the rule written on the lowest is what will be sourced to style the element

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

27
Q

List the three selector types in order of increasing specificity.

A

Id (#example), class (.myClass), type (p, h1, td)

28
Q

Why is using !important considered bad practice?

A

It ignores the order of the cascade and makes conflicting declarations. Understanding and effectively using specificity and cascade can remove need for the !important flag.

29
Q

What does the transform property do?

A

Lets you rotate, scale, skew or translate an element
Modifies the coordinate space of the css model

30
Q

The transition property is shorthand for which four CSS properties?

A

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

31
Q

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

A

Width, height,
These are traits of media features
These are basically CSS conditionals

32
Q

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

A

Viewport

33
Q

What is a breakpoint in responsive Web design?

A

It’s the point (measured in width via pixels) where the items shift either wider or narrower to adjust for the screen size

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

You don’t have to calculate the number of pixels for the 50% everytime the 100% width is different
Or just makes things that are either too small or too big depending on screen size

35
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

CSS works from bottom to top if they’re the same element
@media queries ONLY work because of the source order of the cascading style
Also why they’re always listed at the end of the CSS page
Also make sure it’s in the same page as the original width of where it’s changing, not different CSS file so it loads properly