CSS Flashcards

1
Q

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

A

selector, curly brackets, 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

.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

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 {}

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

hex, rgb, color name(keyword)

bonus points rgba, hsl, hsla

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 boes 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 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

keyword that specifies a special state of the selected element
eg: button:hover{}

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

lets you apply styling to elements in relation to external factors

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, em, rem, pt

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 (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 (everything on one line)

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 elements

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)

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

allows us to move the element relative to where it should be

does not change document flow - purely visual

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

with no other augments - it would be the same

needs top, bottom, left, right to modify

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

A

it is removed from the normal flow - doesn’t affect position of surroundings (used to place elements on top of other elements)

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

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

A

positions relative to the boundary of the previous parent non-statically positioned element

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

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

A

set the containing block to be a non static element (usually position: relative)

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

What are the four box offset properties?

A

top, bottom, left, right

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

What are the four components of “the Cascade”.

A

source order, inheritance, specificity, important rule

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the term "source order" mean with respect to CSS?
styling lower in the style sheet takes priority
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 rule
27
List the three selector types in order of increasing specificity.
element/type > class > id
28
Why is using !important considered bad practice?
overrides cascade
29
What does the transform property do?
lets you rotate, scale, skew, or translate an element
30
Give four examples of CSS transform functions.
rotate, scale, skew, translate
31
The transition property is shorthand for which four CSS properties?
transition-property, transition-duration, transition-timing-function, transition-delay
32
What event is fired when a user places their cursor in a form control?
focus
33
What event is fired when a user's cursor leaves a form control?
blur
34
What event is fired as a user changes the value of a form control?
input
35
What event is fired when a user clicks the "submit" button within a ?
submit
36
What does the event.preventDefault() method do?
if the event does not get explicitly handled, the default action should not be taken as it normally would be ie a default behavior of type checkbox is to be checked, preventDefault() prevents box from being checked
37
What does submitting a form without event.preventDefault() do?
Automatically load the form values.
38
What property of a form element object contains all of the form's controls.
elements property
39
What property of form a control object gets and sets its value?
value
40
What is one risk of writing a lot of code without checking to see if it works so far?
no way to know where the code is bugged
41
What is an advantage of having your console open when writing a JavaScript program?
immediate feedback
42
Does the document.createElement() method insert a new element into the page?
no, it has to be appended first
43
How do you add an element as a child to another element?
element.appendChild()
44
What do you pass as the arguments to the element.setAttribute() method?
('name of the attribute', 'attribute value')
45
What steps do you need to take in order to insert a new element into the page?
1) query select element to be appended to 2) create element 3) append element
46
What is the textContent property of an element object for?
gets the text content of the element | also allows us to set the text content of the element
47
Name two ways to set the class attribute of a DOM element.
element.setAttribute() and className property and classList property
48
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
reusability
49
Give two examples of media features that you can query in an @media rule
min width, max width, height, etc
50
Which HTML meta tag is used in mobile-responsive web pages?
viewport
51
Where should media queries go?
at the bottom of the css sheet to override existing defaults for web
52
What is the event.target?
returns the object (dom element) that the event is attached to/where the event originated from
53
Why is it possible to listen for events on one element that actually happen its descendent elements?
event bubbling
54
What DOM element property tells you what type of element it is?
.tagName
55
What does the element.closest() method take as its argument and what does it return?
takes a selector and returns closest node that matches the selector
56
How can you remove an element from the DOM?
remove() ON the element that you want to be removed
57
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?
take advantage of bubbling and put event listener on the parent element
58
What is the event.target?
the object for the element where the event originated from
59
What is the affect of setting an element to display: none?
does not show the element on the web page
60
What does the element.matches() method take as an argument and what does it return?
takes a selector as an argument, returns a boolean
61
How can you retrieve the value of an element's attribute?
getAttribute()
62
At what steps of the solution would it be helpful to log things to the console?
verifying element location, values of attributes
63
If you were to add another tab and view to your HTML, but you didn't use event delegation, how would your JavaScript code be written instead?
would need to include event listeners for each individual element
64
If you didn't use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?
a huge if conditional code block
65
What is a breakpoint in responsive Web design?
breakpoints determine where the styling would change (any media features)
66
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?
with percentages the layout adapts to the exact dimensions of the viewport's width.
67
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?
The lower one wins due to css rules
68
What is JSON
text-based data format
69
What are serialization and deserialization?
how data is transformed into bytes and back
70
Why are serialization and deserialization useful?
Allows for storage and withdrawal from storage
71
How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify
72
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse