Zero to Hero Flashcards

(40 cards)

1
Q

What does CSS stand for?

A

Cascading Style Sheets — a language for describing the presentation of HTML documents.

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

What are the three ways to add CSS to an HTML page?

A

Inline styles (style attribute), internal stylesheet (<style> tag in <head>), and external stylesheet (<link></link> to a .css file).</style>

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

What is a CSS rule made up of?

A

A selector (what to style) and a declaration block (how to style it), e.g. p { color: red; }

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

What is the universal selector?

A

The asterisk (*) — it matches every element on the page.

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

What is the difference between a class selector and an ID selector?

A

A class (.name) can be reused on many elements. An ID (#name) should be unique per page and has higher specificity.

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

What does the cascade mean in CSS?

A

When multiple rules target the same property on the same element, the cascade algorithm decides which wins based on origin, specificity, and source order.

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

What is specificity and how is it ranked?

A

The weight of a selector. Inline styles beat IDs, IDs beat classes/attributes/pseudo-classes, which beat type selectors/pseudo-elements.

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

What does !important do and why should you avoid it?

A

It forces a declaration to win the cascade regardless of specificity. It makes debugging painful and should be a last resort.

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

What is inheritance in CSS?

A

Some properties (like color and font-family) pass their value down to child elements automatically. Others (like border and margin) do not.

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

Name the four areas of the CSS box model from inside out.

A

Content, padding, border, margin.

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

What is the difference between content-box and border-box?

A

content-box: width/height = content only, padding and border add to the total. border-box: width/height includes content + padding + border.

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

What is margin collapsing?

A

When adjacent vertical margins overlap, they merge into one margin equal to the larger value instead of adding together.

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

What is the difference between block and inline elements?

A

Block elements break onto a new line and take full width. Inline elements flow within text and ignore width/height.

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

What does display: inline-block do?

A

The element flows inline like text but respects width, height, and vertical margin/padding like a block.

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

What does display: none do vs visibility: hidden?

A

display: none removes the element from layout entirely. visibility: hidden hides it visually but it still takes up space.

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

How does position: relative work?

A

The element stays in normal flow but can be offset with top/right/bottom/left. Its original space is preserved.

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

How does position: absolute work?

A

The element is removed from flow and positioned relative to its nearest positioned ancestor (or the viewport if none).

18
Q

What does position: sticky do?

A

The element scrolls normally until it hits a threshold (e.g. top: 0), then it sticks in place until its parent scrolls out of view.

19
Q

What is z-index and when does it work?

A

It controls stacking order of overlapping elements. It only works on positioned elements (not static).

20
Q

How do you create a flex container?

A

Set display: flex on the parent. Its direct children become flex items.

21
Q

What are the main axis and cross axis in flexbox?

A

The main axis follows flex-direction (row or column). The cross axis is perpendicular to it.

22
Q

What does justify-content do?

A

Distributes flex items along the main axis — values include flex-start, center, space-between, space-around, space-evenly.

23
Q

What does align-items do?

A

Aligns flex items along the cross axis — values include stretch (default), flex-start, center, flex-end, baseline.

24
Q

What does flex: 1 mean?

A

Shorthand for flex: 1 1 0 — the item grows to fill available space, can shrink, with a basis of zero.

25
How do you create a CSS grid?
Set display: grid on the container and define tracks with grid-template-columns and/or grid-template-rows.
26
What is the fr unit in grid?
A fractional unit representing a share of available space, e.g. 1fr 2fr gives the second column twice as much room.
27
What does minmax(100px, 1fr) do in a grid track?
The track will be at least 100px but can grow to fill a fraction of the remaining space.
28
How do you place a grid item across multiple columns?
Use grid-column: start / end, e.g. grid-column: 1 / 3 spans from line 1 to line 3.
29
What is the gap property?
Sets gutters between grid or flex items without margins. Accepts one value (all gaps) or two (row-gap column-gap).
30
What is a CSS custom property (variable)?
A reusable value defined with -- prefix, e.g. --brand-color: #0066ff; and accessed via var(--brand-color).
31
Where should you typically define CSS custom properties?
On :root for global access, though they can be scoped to any selector.
32
What does the var() fallback do?
var(--color, red) uses red if --color is undefined. The fallback is everything after the first comma.
33
What is a CSS transition?
A smooth animation between two states triggered by a property change, controlled by transition-property, transition-duration, transition-timing-function, and transition-delay.
34
What is a CSS @keyframes animation?
A multi-step animation defined with waypoints (0% to 100%) that can run automatically, loop, and reverse without needing a trigger.
35
What does animation-fill-mode: forwards do?
The element retains the styles from the last keyframe after the animation ends.
36
What is a media query?
A conditional rule that applies styles based on device characteristics, e.g. @media (max-width: 768px) { ... } for smaller screens.
37
What does clamp() do?
Returns a value clamped between a minimum and maximum, e.g. font-size: clamp(1rem, 2.5vw, 2rem) for fluid typography.
38
What is the difference between em and rem?
em is relative to the parent element's font size. rem is relative to the root () font size — more predictable for consistent sizing.
39
What are cascade layers (@layer)?
A way to organize CSS into named layers with explicit precedence, giving you control over the cascade without fighting specificity.
40
What is a stacking context and how is one created?
An isolated z-axis scope for element stacking. Created by positioned elements with z-index, elements with opacity < 1, transform, filter, and several other properties.