CSS Flashcards

1
Q

Can you describe the box model in CSS?

A

The CSS box model is a shorthand referring to the width, height, padding, border, and margin properties applied to an element with CSS.

These five properties make up how the browser calculates the size of the “box” that element takes up on the page, affecting the total size of the element, how it is positioned, and how it displaces other elements on the page.

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

What are the different ways you can use the position property in CSS?

A

static
relative
absolute
fixed
sticky

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

What is CSS selector specificity?

A

Specificity is the algorithm used by browsers to determine which CSS declaration is most relevant to a given element, to determine how to style it.

MDN Docs

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

What’s the difference between “resetting” and “normalizing” CSS?

A

Both of them are ways to deal with built-in browser styling.

Resetting aims to remove it.

Normalizing aims to make it consistent across browsers.

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

Describe Floats and how they work.

A

The float CSS property places an element on the left or right side of its container, allowing text and inline elements to wrap around it.

MDN Docs

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

Describe z-index and how stacking context is formed.

A

The z-index CSS property sets the z-order of a positioned element and its descendants or flex items.

Overlapping elements with a larger z-index cover those with a smaller one.

MDN Docs

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

Which clearing techniques do you know of?

A

There are several techniques:
1. Adding overflow: auto to the container
2. Adding clear: both to a new element or pseudo element placed right after the container
3. Adding display: flow-root; to the container

The third option is the most modern and currently accepted one. See CSS Tricks article on this.

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

How would you approach fixing browser-specific styling issues?

A

Use media queries

Alternatively, reset or normalize your CSS to avoid the problem.

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

How do you serve your pages for feature-constrained browsers?
What techniques/processes do you use?

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

What are the different ways to visually hide content (and make it available only for screen readers)?

A

To make the content accessible by screen readers, you could use the aria-describedby or aria-labelledby attributes.

To visually hide it, you could either clip the content, push it out of the browsers’ visible viewport, or set them to be transparent.

Read more.

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

What’s the use of media queries?

A

Media queries allow you to apply CSS styles depending on a device’s general type (such as print vs. screen) or other characteristics such as screen resolution or browser viewport width.

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

Can you give an example of an @media property other than screen?

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

Explain how a browser determines what elements match a CSS selector.

A

From right to left

The browser starts at the right-most part of the selector and work its way up the DOM tree.

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

What is the difference between CSS Flexbos and Grid?

A

Flexbox was designed for one-dimensional layouts (either a row or a column).

Grid was designed for two-dimensional layouts (rows and columns at the same time).

MDN Docs

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

What are the ways to position an element vertically?

A

Depending on the situation you may use vertical-align or flexbox.

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

What is the difference between a block level element and an inline element?

A

A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can within its container).

An inline element does not start on a new line and only takes up as much width as necessary.

17
Q

Can you explain the difference between px, em and rem?

A

px is an absolute length unit.
em and rem are relative length units.

em is relative to the font size of the parent element.
rem is relative to the font size of the root element.

MDN Docs

18
Q

Which techniques can you use when working with retina graphics?

A

Retina graphics require serving higher resolution images, this can be achieved using the media and size attributes.