General CSS Flashcards

1
Q

What does “last rule” mean in CSS?

A

When 2 selectors have an equal specificity weight - the latest rule (or the one further down in the CSS) will take precedence.

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

What are text-transform values?

A
text-transform: uppercase;
                          lowercase;
                          capitalize;
                          inherit;
                          none;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you select (i.e. target) the general sibling of another element?

(general sibling combinator)

A

child-element-name ~ sibling.element.name

ex.

img ~ p {
color: red;
}

All paragraphs that are the sibling of an image will be red.

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

How do you target the first child of an element?

A

element-name: first-child

ex.

div: first-child {
color: blue;
}

Elements (like a paragraph or link) that is the first child of a div will appear blue.

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

What property and value would you use to remove the default underlining beneath <a> tags?</a>

What are other possible values of this property? </a>

A

text-decoration: none;

text-decoration: none;
underline;
overline;
strikethrough;

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

What is the descendant selector?

A

The descendant selector is how you select all the elements (with the same description/semantic markup) that are a descendant (child, grandchild, etc etc.) of a specified element.

It is used by placing only a space between the parent and it’s descendant.

ex.

div p {
font-family: sans-serif;
}

Now all paragraphs that are inside a div (its children) will be sans-serif.

TIP - using the universal selector will target all the descendants of an element, regardless of type.

div * {
font-family: sans-serif;
}

All elements inside the div will now use sans-serif fonts, even if they are h1, h2, p, etc.

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

How do you write a child selector in CSS?

A

element-parent > element.child

ex.

div > p {
text-transform: uppercase;
}

Now all paragraphs that are the children of a div will be uppercase.

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

What is “ div:p { color:blue; } “ an example of?

A

The first-child selector, which allows you to target the first child of an element or group of elements.

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

What is “h1 + p { color:red; }” an example of?

A

The adjacent sibling selector (aka adjacent sibling combinator)

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

What is the adjacent sibling selector (combinator) and how do you write it?

A

The adjacent sibling selector is a way to target, or select, only elements that are the direct sibling to another. It is written using a + between the sibling elements.

ex.

HTML: 
< div >
    < h1 >Title< /h1 >
    < p >fancy words< /p >
    < h2 >Han shot first< /h2 >
    < p >Greedo was a punk anyway< /p >
    < p >But have you seen baby yoda?< /p >
< /div > 

CSS:
h2 + p {
color: purple;
}

Only “Greedo was a punk anyway” will appear purple on the page, because the other paragraphs were not direct siblings of the h2.

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

What is the CSS universal selector?

A

*

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

What is CSS grouping and why is it useful?

A

CSS grouping is a way to group several elements and style them at once. It is written by placing a comma between the elements.

ex: h1, h2, p { font-family: cursive; }

Grouping allows developers to minimize the code, so all the h1’s, h2’s and p’s on the page in the example above will share the same font style. Instead of 3 rules, we only need one. This keeps code clean, easier to read, and more friendly to those who wish to build off of your code later on.

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

How does a developer make a rule targeting a class in code?

A

Placing a period before the given class name, and spelling it exactly as it’s written in the html.

ex: .nav-container { text-decoration: none; }

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

How does a developer make a rule targeting an element with an id?

A

Placing a # before the id name, writing it exactly as it appears in the html.

ex: #page-top { width: 80%; }

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