CSS Flashcards

1
Q

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

A

A rule set has a selector and a declaration block
A declaration block consists of at least one declaration
A declaration is one property and one 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

“.className”

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

Just use the letters of the element without the “<>”, case sensitive
Separate by commas if grouping multiple (called a group 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 itsidattribute?

A

#elementID

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

HEX codes
RGB (or RGBA with CSS3)
Names (white, black, blue, red)
HSLA (CSS3)

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

Technically the content is also part of the box model, so width and height can also be properties of the box model

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

Keyword added to selectors to target elements under certain states
Class applied by the browser (not by the developer) under certain situations

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 can be useful for responding to users, altering behavior of elements that makes it easier for users to understand the intended uses. It also makes the page feel more responsive/interactive.
Style elements based not just on content but external factors to the content. (History, status, position)

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, percentage (% of 16px, the default) rem, and ems (width of the letter “m”)

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 defaultflex-directionof aflexcontainer?

A

The flex-direction of a container will be row by default, meaning items will be arranged horizontally 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

It will be nowrap by default, meaning all items will fit on one line.

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

What is the unit vh?

A

Viewport height, 100vh is 100% of the viewport height.
Not commonly used because we don’t commonly set height with webpages.
May be used to set a container to be a certain height relative to the viewport rather than a height based on the content inside (centering an image on a page).

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

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

A

div elements are block elements

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

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

A

row (left to right)

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

What is the purpose of the container class in the layout class system?

A

Holds the rows and columns of the page layout

Generally only has a max-width and a margin

19
Q

What is the purpose of the row class in the layout class system?

A

Sections off vertical chunks of content in the page
Is usually a flexbox (display: flex)
Contains columns

20
Q

What is the purpose of the column class in the layout class system?

A

Sections off horizontal chunks of content in the page
Each column class should have only a width value
Can contain rows (which would contain further columns)

21
Q

What is the difference between a utility class and a semantic class?

A

Utility classes are named by what they do and are highly reusable (example: .bold-text)
Semantic classes are named by what they refer to and are highly specific (example: .about-section)

22
Q

Why should CSS rules (almost) never apply to IDs?

A

Because IDs have to be completely unique, rulesets with ID selectors are never reusable! Class selectors are generally better

23
Q

How long should utility classes generally be?

A

Usually around 2-3 declarations

24
Q

What is thedefaultvalue for thepositionproperty of HTML elements?

A

position: static;

25
Q

How does settingposition: relativeon an element affect document flow?

A

It doesn’t affect document flow, things are positioned as they should be

26
Q

How does settingposition: relativeon an element affect where it appears on the page?

A

It doesn’t affect where it appears, but the element can now be shifted from that position using top, bottom, left, and right (takes, px, %, and ems)

27
Q

How does settingposition: absoluteon an element affect document flow?

A

The element is taken out of the document flow and other elements act as if it isn’t there

28
Q

How does settingposition: absoluteon an element affect where it appears on the page?

A

Once the other elements are properly situated, the absolute element that was taken out of its place now sits relative to the first non-static/non-positioned parent.
If there is no non-static/non-positioned parent, the element is positioned relative to its containing block (in the code, what it’s nested under)

29
Q

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

A

Because absolutely positioned elements are positioned relative to the closest non-static/non-positioned ancestor, you would make the containing block non-static/non-positioned (e.g. set the containing block to position: relative)

30
Q

What are the four box offset properties?

A

top, bottom, left, right

31
Q

What are the four components of “the Cascade”.

A

Source Order
Inheritance
Specificity
!important

32
Q

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

A

If an element has two competing CSS rules with the same level of specificity applied, the one that comes later in the stylesheet takes precedence.
Documents loaded in later in the HTML `` take precedence over earlier ones too

33
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

Some CSS properties are inherently inherited from parent elements if not specified.

34
Q

List the three selector types in order of increasing specificity.

A

element < class < id

35
Q

Why is using!importantconsidered bad practice?

A

It breaks the natural cascade which makes it difficult to debug issues

36
Q

What does the transform property do?

A

The transform property allows an element to be scaled, skewed, rotated, or translated depending on what transform-function is used as the value
Elements are rendered on a coordinate plane, and transform allows us to modify the coordinate space (which has origin at the top-left corner)

37
Q

Give four examples of CSS transform functions.

A

rotate, translateY, skew, scale, translateX

38
Q

Thetransitionproperty is shorthand for which four CSS properties?

A

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

39
Q

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

A

Screen width (min-width), screen height, orientation, aspect ratio, ability to have hover

40
Q

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

A

The viewport meta tag, like meta name="viewport" content="width=device-width, scale-resolution=1"

41
Q

What is abreakpointin responsive Web design?

A

A breakpoint is a condition that, when met, will adjust the CSS of the page to be responsive to the device/conditions

42
Q

What is the advantage of using a percentage (e.g.50%)widthinstead of a fixed (e.g.px)widthfor a “column” class in a responsive layout?

A

Using pixels would create potentially inconsistent breakpoints across devices with various numbers of pixels/scaling rules. Percentages are more universal and are more closely related to how the content should be displayed.

43
Q

If you introduce CSS rules for a smallermin-width_after_the styles for a largermin-widthin your style sheet, the CSS rules for thesmallermin-widthwill “win”. Why is that?

A

The “winning” rule for conflicting CSS rules of the same specificity will be the one later in the sheet. Of course, the condition for the smaller min-width will still be true when the screen size exceeds the larger one, so it is still true. (Source Order)