M2- Different types of selectors (CSS) Flashcards

1
Q

What are CSS selectors?

A

CSS selectors are patterns used in CSS to select the HTML elements you want to style. Selectors help apply styles to specific elements, groups of elements, or elements with certain attributes.

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

What is an Element Selector and how do you use it?

A

An Element Selector targets all HTML elements of a specific type. You use it by writing the name of the element you want to style, followed by curly braces containing the CSS properties and values.

**Syntax:** element { property: value; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an ID Selector and how do you use it?

A

An ID Selector targets a specific element with a unique ID attribute. ID selectors are prefixed with a # symbol.
Syntax: #id { property: value; }

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

What is a Class Selector and how do you use it?

A

Class Selector targets elements based on their class attribute. Unlike IDs, classes can be used on multiple elements.

Syntax: .class { property: value; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Universal Selector and how do you use it?

A

A Universal Selector targets all elements on the page. It is used to apply global styles.

Syntax: * { property: value; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an Attribute Selector and how do you use it?

A

An Attribute Selector targets elements based on the presence or value of a specific attribute.

Syntax: element[attribute], element[attribute="value"]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Descendant Selector and how do you use it?

A

A Descendant Selector targets elements that are descendants of another element, regardless of their position in the hierarchy.

Syntax: ancestor descendant { property: value; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Child Selector and how do you use it?

A

A Child Selector targets elements that are direct children of another element, meaning they are nested directly within their parent.

Syntax: parent > child { property: value; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a Pseudo-class Selector and how do you use it?

A

A Pseudo-class Selector targets elements in a specific state, such as when they are hovered over, focused, or active.

Syntax: selector:pseudo-class { property: value; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly