CSS Flashcards
(54 cards)
What is CSS and what is it used for?
Cascading Style Sheets (CSS) is a textual language used to control the look and layout of webpage content.
What is a CSS Rule?
A CSS Rule specifies styling properties for specific HTML elements.
What HTML tag is used to attach a .css to a .html?
< link >
What is the syntax of a CSS rule?
- A selector specifying the HTML element(s) to which the specific style rule applies
- A declaration block containing one or more declarations separated by semicolons
What are common CSS Rule Properties?
- background-color
- color
- font-Family
- font-size
- padding
- margin
What is a CSS color?
A pre-defined name, or an rgb value.
What is a CSS declaration?
A CSS property followed by a colon (:) and the value
What are the 3 ways CSS can be applied to HTML?
- inline style (CSS declarations inside an elements style attribute)
- embedded stylesheet (CSS rules in the style element in the documents head)
- External Stylesheet (A separate file imported into the HTML via a link element)
How are conflicts between CSS rules resloved?
By the degree of specificity; the more specific, the higher the priority.
What are the 3 common CSS selector types?
- element selector (matches elements with specified names)
- class selector (specified with a period character followed by the class name)
- ID selector (specified with a hash character followed by ID name)
What is a Descendent Selector?
Specified with a selector followed by a space and another selector, matches elements that are contained in other elements.
What is a Psuedo-Class Selector?
Specified with a colon character followed by a pseudo-class name, matches elements based on user behavior or element metainformation
What are common examples of Pseudo-Class Selectors?
- :disabled (Element is disabled)
- :hover (Mouse is hovering over the element)
- :empty (Element has no child elements)
- :lang(language) (Element contains text in a specified language.)
- :nth-child(n) (Element is the parent element’s nth child)
How are Class Selectors and Pseudo-Class Selectors combined?
With the class name, colon, then pseudo-class name
What is a Universal Selector, and how is it specified?
The universal selector matches all elements in the webpage. It is specified with the “*” character, but is the default if no element is provided.
What is a Multiple Selector, and how is it specified?
The Multiple Selector matches all listed elements, and is specified by listing the elements separated by a comma.
What is a Child Selector, and how is it specified?
Matches any elements where the second element is a direct child of the first element and is specified with the > character
What are sibling elements?
Elements that share the same parent element
What is a General Sibling Selector, and how is it specified?
Speficied with the ~ character, it matches the second element if the second element occurs after the first element and both elements are siblings.
What is an Adjacent Sibling Selector, and how is it specified?
Specified with the + character, it matches an element that immediately follows another element, where both elements have the same parent.
What is an Attribute Selector, and how is it specified?
It matches elements with the specified attribute or the specified attribute and value, and is specified with the attribute and value enclosed in square brackets.
Ex: img[alt^=”cat”]
What are the common Attribute Selector comparitors?
- = (Attribute has exact value)
- ~= (Attribute contains value)
- ^= (Attribute starts with value)
What is a Psuedo-Element Selector and how is it specified??
Matches parts of elements that are specified with element-name, two colons, and the psuedo element.
Ex: li::after
What are the common pseudo-elements?
- ::after (add style after element)
- ::before (add style before element)
- ::first-line (add style to first line of matched block element)
- ::first-letter (add style to first letter of matched block element)
- ::selection (style selected text)