CSS Selectors Flashcards

1
Q

Combining selectors?

A

h1, h2, h3, h5{
font-family: sans-sarif;
}

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

Descended selector?

A

footer p{
font-size: 13px;
}

Descended selector: The p element is in the footer element
Only applies to that <p> element
</p>

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

Refers to id

A

#

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

Refers to class - Class can be used more than once, preferred method

A

.related

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

Pseudo class syntax?

A

li:first-child{}

First-child is an example of a pseudo class since it does not exist in the HTML
A list of pseudo classes can be found on the MDN reference page

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

Pseudo class reference last child

A

li:last-child{}

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

Pseudo class reference second entry

A

li:nth-child(2){}

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

Pseudo class reference odd entries in list

A

li:nth-child(odd){}

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

What does it do?

article p: first-child{}

A

This would not do anything at all.

Rather use: article : first-child{}

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

What modes can we use for anchor element?
+ syntax
+ order

A

a{} Style link

ALWAYS USE THIS ORDER:

a:link{} Styling the link, overrides previous
a:visited{} If it has been visited
a:hover{}
a:active{} If it is being pressed

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

Chaining pseudo classes and refer to last child only

A

nav a:link:last-child{}

‘Link’ here is the first state of the anchor element. It refers here to the last element of all anchor tags within the nav tag.

nav
<a>Blog</a>
<a>Challenges</a>
<a>Flexbox</a>
<a>CSS Grid</a>
nav

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

Pseudo element first letter

A

Pseudo elements

It is possible to refer to just the first letter in an element with pseudo elements, you write the pseudo element with ::

h1::first-letter{}

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

Pseudo element first line

A

p::first-line{}

You can highlight the complete first line of a paragraph for example

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

This is how you refer to a pseudo element within a sibling

A

h3 + p::first-line{}

When there’s a < p > element straight after an < h3 > element it will color the first line of that < p > element

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

Places the content straight after the last child within that element, so in this after the last character in h2

A

h2::after{}

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

Pseudo element absolute positioning

A

h2::after{}

Set the h2 pseudo element to position:absolute

h2{}

Set h2 element to relative. This way you can position the pseudo element relative to the main element

17
Q

What happens when not using absolute positioning in pseudo element?

h2::before{
position:absolute
….
}

h2{
position:relative
}

A

When not using absolute positioning, the element will be placed before the text

18
Q

What does this do?

article :first-child {
color: red;
}

A

Code looks at sibling childs of article. This could be anything: < p >, < li >, etc

It then addresses the FIRST CHILD OF THOSE SIBLING childs and paints them red. This could be first letter italic text < em > or bold text < strong > within that <p> element in the article.

Or a first list entry of the lists within that article for example</p>

19
Q

Set hover pseudo class on button

A

.button:hover {
color: #000;
background-color: #fff;
}

20
Q

What does ::before do?

A

In CSS, ::before creates a pseudo-element that is the first child of the selected element. It is often used to add cosmetic content to an element with the content property. It is inline by default.

21
Q

What to do when needing a global reset (0px margin and padding)?

A

*{
margin:0px;
padding:0px
}

22
Q

Problem: When having two consecutive grids and you want margin-bottom so you can split them, the margin will be added to all grids which you don’t want. How to resolve?

A

Set
.grid:last-child{margin bottom: 0}
Or
.grid:not(:last-child){margin bottom: 9.6rem}