CSS Flashcards

1
Q

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

A

selector & declaration (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

.classname { }

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

elementname { }

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

idname { }

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, color names

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, margin, padding

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 keyword added to a selector that specifies a special state of the element

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

makes it easier to apply styling without having to add additional classes

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

pixels, percentages, ems

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

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

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

A

they are block-level elements that take up the entire width of the container

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

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

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

A

static

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 document flow?

A

does not affect document flow

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

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

A

no change, but can use box offset properties to move element; neighboring elements will not be affected

20
Q

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

A

takes element out of document flow

21
Q

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

A

must use box offset properties to specify where the element should appear in relation to the non-static container

22
Q

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

A

set parent to position: relative

23
Q

What are the four box offset properties?

A

top, bottom, left, right

24
Q

What are the four components of “the Cascade”.

A

source order, inheritance, specificity, !important

25
What does the term "source order" mean with respect to CSS?
the order that CSS rules are written in the stylesheet
26
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance - can occur if no CSS for that property is directly declared for the children
27
The transition property is shorthand for which four CSS properties?
transition-property, transition-duration, transition-timing-function, transition-delay
28
Give two examples of media features that you can query in an @media rule.
min-width; max-width
29
Which HTML meta tag is used in mobile-responsive web pages?
viewport
30
What is the event.target?
a reference to the object onto which the event was dispatched
31
Why is it possible to listen for events on one element that actually happen its descendent elements?
event flow (event bubbling)
32
What DOM element property tells you what type of element it is?
tagName
33
What does the element.closest( ) method take as its argument and what does it return?
takes a CSS selector string, returns itself or the closest parent node that matches the selector
34
How can you remove an element from the DOM?
ChildNode.remove( )
35
If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?
add an event listener to the parent element, then check event.target to determine the actual clicked node
36
What is a breakpoint in responsive Web design?
the point at which a media query is introduced, usually selected to be the size where the content starts to break in some way
37
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?
so you don't need to know the exact pixel count of the screen
38
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?
source order - if two rules are declared for the same thing, the bottom one will always be used
39
What is JSON?
a standard text-based format for representing structured data based on JavaScript object syntax
40
What are serialization and deserialization?
serialization is converting a native object to a string so it can be transmitted across the network, and deserialization is converting a string to a native object
41
Why are serialization and deserialization useful?
so you can transmit data across a network
42
How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify( )
43
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse( )
44
How do you store data in localStorage?
localStorage.setItem( keyName, keyValue)
45
How do you retrieve data from localStorage?
localStorage.getItem( keyName )
46
What data type can localStorage save in the browser?
string
47
When does the 'beforeunload' event fire on the window object?
when the window, the document, and its resources are about to be unloaded