Intro to CSS Flashcards

Introduction to basic CSS syntax, precedence

1
Q

How is the following style rule selector interpreted by the browser?

div, p { width: 50px; }

A

Apply associated style to all div and p elements

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

What are the two parts of a style rule?

A

the selector and definition

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

How are multiple styles separated

A

”;” character

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

True or False: a class attribute for an element can have multiple classes

A

True

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

True or False: the order of classes specified in a class attribute for an element matters in determination of CSS precedence

A

False

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

True or False: the style attribute of an element can have multiple rules defined

A

True

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

For a given style rule, e.g. the height of an image, order the precedence of the following:

A. rule defined by element selector at the bottom of the < body > element  
B. rule defined by class selector at the bottom of the page
C. rule inside style attribute of an element 
D. rule with id selector inside < style > tag at the top of < body >
E. rule with element selector inside external style sheet in < head > element
F. rule defined by id selector defined inside an external sheet inside the < head > element
A

C, D, F, B, A, E

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

What are the two guidelines to follow when determining CSS precedence?

A

specificity then order, i.e. more specific wins and when two rules have the same level of specificity, the order wins

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

Given the class attribute below

class=”blank non-blank”

do the classes “blank” and “non-blank” have the same specificity, or if not, which one is more specific–the first or last?

A

Same specificity

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

How is the following style rule selector interpreted by the browser?

img.framed { width: 50px; }

A

all < img > elements who also have a class framed

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

What is the difference between the following two style rule selectors?

ul li { margin: 0 0 5px 0; }
ul > li { margin: 0 0 5px 0; }

A

The first selector (space) is a descendant selector and will select ANY < li > at ANY level inside the < ul >, which means it will affect embedded lists.

The second selector (>) is a child combinator selector and will only select < li > elements that are direct children of the < ul >, which means embedded lists will not be affected.

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