CSS Flashcards

1
Q

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

A

o Selector, declaration block, property, 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

o Use a period “.class”

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

o Simply write the element name – nothing else.

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

o Use a # sign

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

o rbg, hex codes, name of colors, etc.

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

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

A

o rgb, hex codes, name of colors, etc.

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

• What CSS properties make up the box model?

A

o Border, margin, padding (page 307), and content

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

• Which CSS property pushes boxes away from each other?

A

o The MARGIN is an invisible space around your box.
o It pushes other elements AWAY from the box.
o Margins can have positive or negative values. Setting a negative margin on one side of your box can cause it to overlap other things on the page. Whether you are using the standard or alternative box model, the margin is always added after the size of the visible box has been calculated.

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

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

A

o Padding
o Padding is the space between the border of a box and any content contained within it. Adding padding can increase the readability of its contents.
 Padding is additional space – and that comes with problems.
 Box-sizing border box – it makes it so that the sizing is applied to the border and that which is inside of it.

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

• What is a pseudo-class?

A
o	A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s).
o	For example, :hover can be used to change a button's color when the user's pointer hovers over it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

• What are CSS pseudo-classes useful for?

A

o SCALABILITY – no need to write long code if you can have it uniform.
o Pseudo-classes let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator (:visited, for example), the status of its content (like :checked on certain form elements), or the position of the mouse (like :hover, which lets you know if the mouse is over an element or not).
o Applying style
o nth child

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

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

A

o em
o px
o ##%

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

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

A

o font-family
o The font CSS shorthand property sets all the different properties of an element’s font. Alternatively, it sets an element’s font to a system font.

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

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

A

o row

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

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

A

o No wrap

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

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

A

o They are block level elements

17
Q

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

A

o Row

o Purpose of the container class – is the boundary for all of our content.

18
Q

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

A

o Static or Normal flow
o Every block-level element appears on a new line – causing each item to appear lower down the page than the previous one.
o Even if you specify the width of the boxes and there is space for two elements to sit side by side, they will not appear next to each other.
o The paragraphs appear one after the other, vertically down the page.

19
Q

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

A

o This moves an element from the position it would be in normal flow, shifting it to the top, right, bottom, or left of where it would have been placed.
o This DOES NOT AFFECT the position of surrounding elements.
o They stay in the position they would be in normal flow.
 THINK INDENTATION?

20
Q

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

A
21
Q

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

A

o Absolute positions the element in relation to its CONTAINING element
o It is taken OUT of normal flow – meaning that it DOES NOT affect the position of any surrounding elements
 They ignore the space it would have taken up.
o ABSOLUTE positioned elements move as users scroll up and down the page.
o It is COMPLETELY REMOVED

22
Q

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

A

o An element with a position absolute will appear at the TOP LEFT
 It will sit at the top of its nearest ancestor that is NOT STATIC

23
Q

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

A
24
Q

• How would you make it stop at a certain level/section?

A

o Position fixed would work / but there’s more to it.

o Set a position property on that element and set it to NOT STATIC

25
Q

• What are the four box offset properties?

A

o Top, left, right, bottom

26
Q

• What are the four components of “the Cascade”.

A

o Source order, inheritance, specificity, important.

27
Q

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

A

o Source order is the process in CSS of deciding what styling gets applied to an element based on the order of the rule set in your style sheet.
o Those that are lower are of more importance than the ones above in the stylesheet.

28
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

o Inheritance – it’s not applicable to everything… only a subset… any old property can be made inherit by using that property, but you don’t want to do that.
o Text stuff gets inherited.

29
Q

• List the three selector types in order of increasing specificity.

A
o	Type selector, class selector, and ID
         [element, class, and ID IN THAT ORDER]
30
Q

• Why is using !important considered bad practice?

A

o It reverses the cascade and overrides EVERYTHING.

31
Q

• What does the transform property do?

A

o The transform CSS property lets you rotate, scale, skew, or translate an element.
o It modifies the coordinate space of the CSS visual formatting model.

32
Q

• Give four examples of CSS transform functions.

A
o	Matrix
o	Translate
o	Scale
o	Rotate
o	Skew
33
Q

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

A

o Min width, max width

34
Q

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

A

o Viewport meta tag
o The existence of this element is to fix a different fix –
o In the early days of mobile browsing, websites on phones like blackberries were very small – they were designed for larger screens.
o To mitigate that, they implemented a “fix”, if your screen was very small

35
Q

• What is a breakpoint in responsive Web design?

A

o A breakpoint in a responsive design 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.
o Boundary where the page design changes

36
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

o Advantage – it will calculate a percentage vs. pixels being fixed.

37
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

o Because it loads in SOURCE ORDER.
o Only reason media queries work is because of SOURCE ORDER.
o They must be on the bottom of the doc so that it can be applied to the above css rulesets.
o If you have regular css rules below the media queries, that’s trouble.
o Media queries MUST be in the same stylesheet as that rule!!