Unit 7
Unit 7
id=36
884
Describing People ~
Who is it?
Description: Listen to the
descriptions. Who is being
described?
Selector: A CSS selector is a pattern used to select and target specific HTML elements in a web page
for styling or manipulation.
Element Selector: It selects HTML elements by their element type. For example, the selector "p"
targets all paragraph elements.
Class Selector: It selects HTML elements by their class attribute. The selector ".classname" targets all
elements with the specified class.
D Selector: It selects an element by its unique ID attribute. The selector "#elementID" targets the
element with the specified ID.
Descendant Selector: It selects an element that is a descendant of another specified element. The
selector "parent descendant" targets the descendant element.
Child Selector: It selects an element that is a direct child of another specified element. The selector
"parent > child" targets the child element.
Universal Selector: It selects all HTML elements on the page. The selector "*" targets all elements.
Attribute Selector: It selects elements based on their attributes. For example, the selector
"[type='text']" targets elements with the attribute "type" set to "text."
Pseudo-class Selector: It selects elements based on their state or position. For example, the selector
"a:hover" targets links when they are being hovered over.
Pseudo-element Selector: It selects a specific part of an element. The selector "p::first-line" targets
the first line of paragraphs.
Grouping Selector: It groups multiple selectors together and applies the same styles to all of them.
For example, "h1, h2, h3" targets multiple heading elements.
Attribute Value Begins With Selector: It selects elements whose attribute value begins with a specific
string. For example, "input[type^='submit']" targets input elements with a "type" attribute starting
with "submit."
True or False Quiz: CSS Selectors
Instructions: Determine whether the following statements are true or false based on the provided CSS selectors
dictionary.
Question 2: How do you select an element based on its class attribute using a
CSS selector?
Question 4: Explain the purpose of the descendant selector in CSS and provide
an example.
Question 5: Which selector would you use to target all HTML elements on the
page?
functionality.
Task 1: Choose the correct CSS selector that targets all paragraph elements. a) .paragraph b)
#paragraph c) p d) .p
Task 2: Which selector is used to target elements with the class "highlight"? a) highlight b)
Task 3: What does the attribute selector "a[href^='https']" target? a) All anchor elements b)
Anchor elements with "https" in their href attribute c) Anchor elements with a URL starting
Task 4: Choose the correct CSS selector to target the first child element of a div. a) div:first-
Task 5: Which selector targets the last element with the class "item" in a list? a) .item:last-