Css Stuff Flashcards

1
Q

How do you select an element in CSS, which is a direct child of another element?

A

section > p

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

How do you select an element in CSS, which is a child of another element?

A

section p

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

How do you select an element in CSS, which is the next sibling of another element?

A

p + p

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

How do you select a certain div that has a class, but not other elements with same class?

A

div.class

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

How do you select all next elements that are beside div?

A

div ~ elements

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

How do you select a first child of type ‘p’ inside a div?

A

div p:first-child

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

How do you select an element, that is the only element inside of a div?v

A

div element:only-child

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

How much specificity points are classes worth? IDs? Tags? Important or inline styles? To override a rule, do you need more or less specificity?

A

Tags : 1
Classes : 10
IDs: 100
Important and inline: 1000

You need more

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

What does CSS rule “position:static” do?
What about relative and absolute?
Fixed?

A

Position static is default position that means the element is unpositioned

Position relative is just like static, but can be moved by using top, left, bottom, right. Gap left by this is not filled by other elements

Position fixed is relative to viewport. Does not leave a gap

Position absolute is fixed, but relative to a nearest positioned element. Does not leave a gap too

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

How to select an element that is third in a container

A

element:nth-child(3)

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

How to select a second from last element in container?

A

Element:nth-last-child(2)

This looks at the second element, and only selects it if it’s of type “Element”

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

How to select a first element of a specific class?

A

.class:first-of-type

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

How to select all even elements in a container?
Every Second element of type “element”?
Every second element starting from the third?

A

element: nth-of-type(2n)
element: nth-of-type (even)
element: nth-of-type (2n+3), where 2n is every ‘2’ element, and 3 is an element which is included and started from

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

How to select an element, which is the only one of it’s type inside a container?

A

Container element:only-of-type

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

How to select a last element of it’s class in a container?

A

container .class:last-of-type

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

How to select all empty elements?

A

Div: empty

17
Q

How to select elements that don’t have a class “.meme”?

A

Element:not(.meme)

18
Q

How to select element that has a “name” attribute?

A

element [name] OR [name]

19
Q

How to search for elements that have attribute that starts with “rofl”?

A

Element[attribute^=”rofl”]