HTML Classes Flashcards
Universal Selector
Applies to all (each and every single) elements in a document
Example: * { }
Targets all elements in the page
Type Selector
Targets specific matches (in other words, targets a specific type of element on the page). We use the HTML element tag as the selector.
Example: h1, h2, h3 { }
This would specifically target the h1, h2, and h3 elements.
Class Selector
Matches an element whose class attribute has a value that matches whatever follows the period symbol. Class selectors are reusable.
Ex. .note { }
Targets ANY element whose class value is .note
Ex. p.note { } Targets p elements whose class attribute has a value of note.
Are ID selectors reusable?
ID Selectors are not reusable, they are a unique identifier for an element.
They have the most specificity and carry the most weight.
What does a descendent selector do?
Target elements that are descendants of other elements.
A descendent selector will appear as or, better said, consists of two or more selectors separated by white space.
For example:
p a { }
(the above would cover all a elements that sit inside of a p element [even if there are other elements nested between them, it’s not a problem]).
Do IDs have browser functionality?
Yes, we can use IDs as fragment identifiers to create anchors in a page.
How many IDs can an element have?
An element can only have one ID, and a page can only have one element with the same ID name.
What are common CSS pseudo classes?
:link, :visited, :hover; :active
How do you create a class selector?
You use a period.
Example:
.intro will select all elements with class=”intro”
How do you select an element with an id?
applesauce will select the specific element with id=”applesauce”
You use a hashtag.
Example:
How do you select all of a type of element?
You simply name the element.
Example:
p will select all the paragraph elements
How do you select an element with a class?
You do the element.class combination…. you use a period in between the type of element and the name of the class (this class name is assigned in the index html).
Example:
p.intro will select all < p > elements with class=”intro”< /p >