CSS Flashcards

Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language like HTML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.

1
Q

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

A

Selector and Declaration.

What makes up a Declaration: 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 type?

A

Type selector means matches element names.

h1 { }
h1, h2, h3 { }

(just write the element)

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

In CSS, how do you select an element by its id attribute?

A

id attribute selector means it matches an element whose id attribute has a value that matches the one specified after the pound or hash symbol.

Selecting an element by its id attribute, you use #.

example:
#introduction { }

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

Universal selector

A

Universal selector applies to all elements in the document.

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

Type selector

A

Type selector matches element names.

h1, h2, h3 { }
(Targets the < h1 >, < h2 >, and < h3 > elements.

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

Class selector

A

Matches an element whose class attribute has a value that matches the one specified after the period (or full stop) symbol

. note { }
(Targets any element whose class attribute has a value of note)

p . note { }
(Targets only < p > elements whose class attribute has a value of note.

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

ID selector

A

introduction { }

Matches an element whose id attribute has a value that matches the one specified after the pound or hash symbol.

(Targets the element whose id attribute has a value of introduction)

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

Child selector

A

Matches an element that is a direct child of another.

li > a { }
(Targets any < a > element that are children of an < li > element (not other < a > element in the page)

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

Descendant selector

A

Matches an element that is a descendent of another specified element (not just a direct child of that element)

p a { }
(Targets any < a > elements that sit inside a < p > element, even if there are other elements nested between them.

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

Adjacent sibling selector

A

Matches an element that is the next sibling of another.

h1 + p { }
(Targets the first < p > element after any < h1 > element (but not other < p > elements)

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

General sibling selector

A

Matches an element that is a sibling of another, although it does not have to be the directly preceding element.

h1 - p { }
If you had two < p > elements that are siblings of an < h1 > element, this rule would apply to both.

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

How do you format External CSS?

A

You must create a new styles.css sheet then create a relationship with the html page.

< link href = “ css / styles.css “ type = “ text / css” rel = “ stylesheet “>

This is located in the < head > element and after the < title > element within it.

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

How do you format Internal CSS?

A

< style type = “ text / css “ >

You can style CSS within an HTML page by placing them inside a < style > element, which usually sits inside the < head > element of the page.

The < style > element should use the type attribute to indicate that the styles are specified in CSS. The value should be text / css.

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

Name three different types of values you can use to specify colors in CSS.

A

RGB values, Hex Codes, and Color Name.

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

RGB Values

A

An expression of color in terms of how much red, green, and blue are used to make it up. These are expressed as numbers between 0 and 255.

Example: rgb(100,100,90)

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

Hex Codes

A

6-digit codes that represents the amount of red, green, and blue in a color, preceded by a pound or hash # sign.

Example: #ee3e80

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

Color Names

A

There are 147 predefined color names that the browser can recognize.

Example: DarkCyan

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

What CSS properties make up the box model?

A
  1. margin,
  2. border,
    3.padding,
  3. content that it holds.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which CSS property pushes boxes away from each other?

A

Margin property.

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

Which CSS property add space between a box’s content and its border?

A

Padding property.

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

What is a pseudo-class?

A

A class that the browser applies on its own when circumstances are meant in order for certain features to be interactive with the user.

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

What are CSS pseudo-classes useful for?

A

For users, they make pages more interactive.

For coders, it basically helps writing code more efficient, especially for striped tables.

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

Name two types of units that can be used to adjust font-size in CSS.

A

Pixels and percentages.
The most common are pixels and rem.

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

What CSS property controls the font used for the text inside an element?

A

font-family property.

25
Q

What is the difference between em and rem?

A

em: the responsive font unit; it is the ratio of the default size.
rem: responsive font unit based on the HTML element (it is consistent). It is recommended to use rem.

26
Q

What is the default flex-direction of a flex container?

A

row

27
Q

What is the default flex-wrap of a flex container?

A

no wrap

28
Q

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

A

They are block elements.

29
Q

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

A

row (left to right)

30
Q

What is the purpose of the container class?

A

The purpose of the container class in a layout system is meant to create a section that controls the layout by setting the boundaries of what we are making.

31
Q

What is the purpose of a row class?

A

The row class is meant to section and control vertical chunks of a layout.

32
Q

What is the purpose of a column class?

A

The column class is meant to section off and control horizontal chunks of a layout.

33
Q

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

A

static

is the default value for the position property of HTML elements. That is why it does not need to be stated in css.
But the syntax is:

position: static ;

34
Q

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

A

position relative does not affect the document flow.

35
Q

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

A

It would not affect where it appears on the page but it does seem like it is visually.

It would move from where it would normally sit. The offset properties changes its position (top or bottom and left or right).

36
Q

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

A

absolute positioning takes an element out of document flow and may or may not affect document flow.

37
Q

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

A

absolute value positioning positions the element in relation to its containing element- it is taken out of its normal flow. They act like it is not there. It will move based off of its parent element if it is non-static.

38
Q

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

A

Set a non-static position property on a parent element.

39
Q

What are the four box offset properties?

A

Top or bottom and left or right.

40
Q

Which units would you typically use for values of a property?

A

rem or px (they are precise).

41
Q

What is “Inheritance”?

A

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

In other words, it controls what happens when no value is specified for a property on an element.

42
Q

What are the two CSS categories?

A
  1. Inherited properties: are set to the computed value of the parent element by default. (computed value means the value of a CSS property is the value that is transferred from parent to child during inheritance)
  2. Non-inherited properties: set to initial value of the property by default. (Initial value of a CSS property is the default value)
43
Q

How do you override !important

A

1) Add another CSS rule with !important and either give the selector a higher specificity (adding a tag, id or class to the selector) or
2. add a CSS rule with the same selector at a later point than the existing one.

44
Q

What are the four components of “the Cascade”.

A
  1. Inheritance
  2. Specificity
  3. Source Order
  4. !important
45
Q

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

A

Source order is the order that your CSS rules are written in the stylesheet. The last styling in the stylesheet will ultimately take effect.

46
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

Inheritance - the process by which CSS properties on a child HTML element receives value from a parent element.

47
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

Inheritance - the process by which CSS properties on a child HTML element receives value from a parent element.

So you just apply the style to the parent element.

48
Q

Why is using !important considered bad practice?

A

It makes debugging harder because it breaks the natural cascading in your stylesheet.

49
Q

What does the transform property do?

A

The transform property lets you rotate, scale, skew, or translate an element by modifying the space of the CSS visual formatting model.

50
Q

Give four examples of CSS transform functions.

A

transform: translate
transform: scale *
transform: rotate
transform: skew

  • = common CSS function
51
Q

The transition property is shorthand for which four CSS properties?

A

The transition CSS property is a shorthand property for:
- transition-property,
- transition-duration,
- transition-timing-function, and
- transition-delay.

52
Q

What is a breakpoint in responsive Web design?

A

In responsive design, a breakpoint is the “point” at which a website’s content and design will adapt in a certain way in order to provide the best possible user experience.

53
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

% will help sizes adapt to your viewport size easier while giving it “wiggle room” for that intermediary space between that point while keeping your layout the way you want it. It will always be consistent as well when using % over px.

54
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

Source order. The style that falls lower is “stronger” and will prevail over the style that falls before due to Source Order CSS component.

55
Q

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

A

examples: min-width and orientation

56
Q

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

A
57
Q

What is a breakpoint in responsive Web design?

A

The “points” at which a website’s content and design will adapt in a certain way in order to provide the best possible user experience.

58
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

Using percentages is advantageous because it is a unit that is relative to the viewport so it will adjust accordingly to the size of the viewport while containing the column sizes.

59
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

Source Order: priority is always given to the rule that appears last in the document.