CSS Flashcards

1
Q

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

A

Selectors - indicate which element the rule applies to.
The same rule can apply to more than one element if you separate the element names with commas.

Declarations
Indicate how the elements referred to in the selector should be styles.

Declarations are split into two parts (a property and a value), and are separated by a colon
Property and 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
Use a dot
.class
Use class for CSS
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 a css selector

Matches elements name / write name of element

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
Hashtag and name of ID
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

These express color in terms of how much red, green, and blue are used to make it up.
rgb(100,100,0)

Hex Codes
These are six digit codes that represent the amount of red, green, and blue in a color preceded by a pound or hash # sign.
#ee3e80

Color name
There are 147 predefined color names that are recognized by browsers.
DarkCyan

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

Border - Every box has a border. The border separates the edge if one box from another

Margin - Margins sit outside the edge of the border. You can set the width of a margin to create a gap between the borders of two adjacent boxes.

Padding - is the space between the border of a box and any content contained within it. Adding padding can increase the readability of its content

Content: The area where your content is displayed, which can be sized using properties like width and height.

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

A class applied by the browser when the element is in a selected states

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 is useful for changing appearances of elements based on interaction

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

Pixels - pixels are commonly used because they allow web designers very precise control over how much space their text takes up.

The number of pixels is followed by the letters px.

Percentages - takes percentage of the default size of text or percentage or parent size of text

Ems - equivalent to the width of the letter m
Most common are pixel, em 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 (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

No wrap - try to fit in one row

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

Div elements are block and create a new line

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

This does not affect the position of surrounding elements, they stay in the position they would be in normal flow

19
Q

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

A

It moves the element from the position it would have been during normal flow.

20
Q

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

A

It comes out of the document flow. (Removed out of document flow entirely.)
Other elements take its place
Acts like its not even there

21
Q

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

A

Positions the element in relation to its containing element.
It takes it out of normal flow
Elements move as users scroll up and down in the page

22
Q

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

A

Set the direct parent to position: relative

23
Q

What are the four components of “the Cascade”.

A

Source order - in situations where a property has been declared for an element only once, this is a very straight forward process.
Source order is, simply put, the order that your CSS rules are written in your stylesheet. The styling provided for an element last in your stylesheet is the styling that will ultimately take effect.

Inheritance is the process by which certain CSS properties on a child HTML element can receive value from a parent element, if no CSS for that property is directly declared on the child element.

Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Specificity is based on the matching rules which are composed of different sorts of CSS selectors.
determined by the number of each selector type in the matching selector. When multiple declarations have equal specificity, the last declaration found in the CSS is applied to the element.

!important - gives it the highest priority

24
Q

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

A

The order in which a rule is written

The further down you get in your stylesheet the more important

25
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

The property can be an inherited property or by using inherit as the value to a property

26
Q

List the three selector types in order of increasing specificity.

A
Type selectors (e.g., h1) and pseudo-elements (e.g., ::before).
Class selectors (e.g., .example), attributes selectors (e.g., [type="radio"]) and pseudo-classes (e.g., :hover).
ID selectors (e.g., #example).
27
Q

Why is using !important considered bad practice?

A

because it makes debugging more difficult by breaking the natural cascading in your stylesheets.
The only way to override important is with another important rule

28
Q

​​What does the transform property do?

A

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
Q

Give four examples of CSS transform functions.

A

translateY()
rotate()
scale(parameter1,parameter 2)
skew(parameter1,parameter 2)

30
Q

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

A

viewport

31
Q

The transition property is shorthand for which four CSS properties?

A

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

32
Q

What is a breakpoint in responsive Web design?

A

points at which a media query is introduced are known as breakpoints.

33
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

Percentage is variable. It is a percentage of what the parent element is

Fluidly takes up the space that is available

34
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

The one that is written after overrides the one that was written before

Due to source order and cascading