CSS Flashcards
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language like HTML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
What are the names of the individual pieces of a CSS rule?
Selector and Declaration.
What makes up a Declaration: Property and Value.
In CSS, how do you select elements by their type?
Type selector means matches element names.
h1 { }
h1, h2, h3 { }
(just write the element)
In CSS, how do you select an element by its id attribute?
id attribute selector means it matches an element whose id attribute has a value that matches the one specified after the pound or hash symbol.
Selecting an element by its id attribute, you use #.
example:
#introduction { }
Universal selector
Universal selector applies to all elements in the document.
- { }
Type selector
Type selector matches element names.
h1, h2, h3 { }
(Targets the < h1 >, < h2 >, and < h3 > elements.
Class selector
Matches an element whose class attribute has a value that matches the one specified after the period (or full stop) symbol
. note { }
(Targets any element whose class attribute has a value of note)
p . note { }
(Targets only < p > elements whose class attribute has a value of note.
ID selector
introduction { }
Matches an element whose id attribute has a value that matches the one specified after the pound or hash symbol.
(Targets the element whose id attribute has a value of introduction)
Child selector
Matches an element that is a direct child of another.
li > a { }
(Targets any < a > element that are children of an < li > element (not other < a > element in the page)
Descendant selector
Matches an element that is a descendent of another specified element (not just a direct child of that element)
p a { }
(Targets any < a > elements that sit inside a < p > element, even if there are other elements nested between them.
Adjacent sibling selector
Matches an element that is the next sibling of another.
h1 + p { }
(Targets the first < p > element after any < h1 > element (but not other < p > elements)
General sibling selector
Matches an element that is a sibling of another, although it does not have to be the directly preceding element.
h1 - p { }
If you had two < p > elements that are siblings of an < h1 > element, this rule would apply to both.
How do you format External CSS?
You must create a new styles.css sheet then create a relationship with the html page.
< link href = “ css / styles.css “ type = “ text / css” rel = “ stylesheet “>
This is located in the < head > element and after the < title > element within it.
How do you format Internal CSS?
< style type = “ text / css “ >
You can style CSS within an HTML page by placing them inside a < style > element, which usually sits inside the < head > element of the page.
The < style > element should use the type attribute to indicate that the styles are specified in CSS. The value should be text / css.
Name three different types of values you can use to specify colors in CSS.
RGB values, Hex Codes, and Color Name.
RGB Values
An expression of color in terms of how much red, green, and blue are used to make it up. These are expressed as numbers between 0 and 255.
Example: rgb(100,100,90)
Hex Codes
6-digit codes that represents the amount of red, green, and blue in a color, preceded by a pound or hash # sign.
Example: #ee3e80
Color Names
There are 147 predefined color names that the browser can recognize.
Example: DarkCyan
What CSS properties make up the box model?
- margin,
- border,
3.padding, - content that it holds.
Which CSS property pushes boxes away from each other?
Margin property.
Which CSS property add space between a box’s content and its border?
Padding property.
What is a pseudo-class?
A class that the browser applies on its own when circumstances are meant in order for certain features to be interactive with the user.
What are CSS pseudo-classes useful for?
For users, they make pages more interactive.
For coders, it basically helps writing code more efficient, especially for striped tables.
Name two types of units that can be used to adjust font-size in CSS.
Pixels and percentages.
The most common are pixels and rem.