CSS Flashcards

1
Q

Describe the syntax of a CSS rule-set.

A

A typical CSS rule-set consists of one of more selectors which identifies the HTML elements to be styled, and the declaration block within curly braces, which contains the CSS property name(s) and property value(s), separated by a colon and completed with a semicolon. If there there are multiple property-value sets, they should be separated by semicolons.

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

.class-name

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

Using just the element name, ex: h1, p, div

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

id-name

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, and color names.
-extra-
HSL
HSLA
RGBA
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

The content width and height, padding, border, margin.

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

Margins.
Note: Be aware of margin collapse where the top and bottom margins of elements can collapse into a single margin that is equal to the largest value of the two margins.

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

It’s a keyword added to a selector that specifies a special state of the selected element(s)

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

CSS pseudo-classes are used to add styles to selectors when those selectors meet certain conditions, whether that’s based on the content of the document tree, or on external factors, ex: position of the mouse (hover)

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

Name at least two units of type size in CSS.

A

Px and percentages
-extra-
ems, ex, and rem

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 default flex-direction of a flex container?

A

The default flex-direction of a flex container is row.

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

Nowrap

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

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

A

Row

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

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

A

position: static

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

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

A

It does not affect the position of surrounding elements; they stay
in the position they would be in in normal flow. The elements just moves.

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

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

A

Relative positioning moves an element in relation to where it would have been in normal flow, based on the box offset property values.

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

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

A

It is taken out of normal flow, it does not affect the position of any surrounding elements, it’s like it’s not there.

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

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

A

Absolutely positioned elements move as users scroll up and
down the page. It will position itself in relation to the nearest ancestor container it’s in that has a non-static position property.

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

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

A

They constrain themselves to the first non-static containing block, so it must be set to a position property that is relative or it will go up the chain of parents that have a non-static property on it.

22
Q

What are the four box offset properties?

A

Top, bottom, left, right.

23
Q

What are the four components of “the Cascade”.

A

Source order, Inheritance, specificity, and important keyword

24
Q

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

A

The order that your CSS rules are written in your stylesheet.

25
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Inheritance. NOTE: The inherit keyword, used as the value of the desired property, or if you want all style properties inherited, the short-had property all with a value of inherit.
26
List the three selector types in order of increasing specificity.
Type selector (and pseudo elements), then class selector (and attribute and pseudo-classes), then Id selectors
27
Why is using !important considered bad practice?
Because it makes debugging more difficult by breaking the natural cascading in your stylesheets.
28
What does the transform property do?
The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.
29
Give four examples of CSS transform functions.
Scale() Skew() Rotate() Translate()
30
Give two examples of media features that you can query in an @media rule.
Display-mode, min-width -- Extra – Hover, pointer, monochrome, orientation, device-width, max-width, width and more.
31
Which HTML meta tag is used in mobile-responsive web pages?
*angle bracket* meta name="viewport" content="width=device-width, initial-scale=1" *close angle bracket*
32
What is the purpose of CSS?
To define visual styles and formatting for web pages displayed on different devices and screen sizes.
33
What are the different ways to insert CSS into web pages?
There are three primary ways to insert css styling for web pages: 1) External CSS - defining the css styling in a separate `.css` file. Each HTML page must include a reference to the external style sheet file inside the `` element within the `` section of the HTML document. The `` element should include two attributes: the `rel` attribute that defines the relationship of the linked resource to the current document, here it would be something to the effect of `stylesheet`, and the `href` attribute containing the value of the file path to the the `stylesheet`. 2) Internal CSS - defining the css styling using a `