CSS Flashcards
What does CSS stand for?
Cascading Styles Sheets
What are the two different methods or syntax for writing CSS code?
CSS ruleset and CSS inline style
What is a selector? (Ruleset)
A selector is the beginning of the ruleset used to target the element that will be styled.
Ex:
p {
color: blue;
}
p = the selector
What is a declaration block? (Ruleset)
The code in-between (and including) the curly braces ({ }) that contains the CSS declaration(s).
p {
color: blue;
}
The declaration block = {color: blue:)}
What is a declaration? (Ruleset)
The group name for a property and value pair that applies a style to the selected element.
p {
color: blue;
}
The declaration = color: blue;
What is a property? (Ruleset)
The first part of the declaration that indicates the aspects of the element you want to change. For example, color, font, width, height and border.
p {
color: blue;
}
property = color
What is a value? (Ruleset)
The second part of the declaration. Values specify the settings you want to use for the chosen properties. For example, if you want to specify a color property then the value is the color you want the text in these elements to be.
p {
color: blue;
}
value = blue
Style attribute
The style attribute is used to add CSS inline styles to an HTML element.
What do we often call the CSS code inside the <style> element in a html file?</style>
internal stylesheet
How do we link html and css files?
use the link element to link HTML and CSS files together. The link element must be placed within the head of the HTML file. It is a self-closing tag and requires the following attributes:
- href
- rel -this attribute describes the relationship between the HTML file and the CSS file. Because we are linking to a stylesheet, the value should be set to stylesheet.
What does the type selector do?
A selector is used to target the specific HTML element(s) to be styled by the declaration. The type selector matches the type of the element in the HTML document.
What is the type selector also referred to as?
The type selector is sometimes referred to as the tag name or element selector.
What does the universal selector do?
The universal selector selects all elements of any type. The universal selector uses the * character
* {
font-family: Verdana;
}
What is a common way for selecting an element when working with html and css?
Using the class attribute.
Ex:
p class=’brand’ Sole Shoe Company /p
Important note: Greater than/less than have been removed in code above.
.brand {
}
How can we add multiply classes to an html element?
We can add multiple classes to an HTML element’s class attribute by separating them with a space.
Ex:
.green {
color: green;
}
.bold {
font-weight: bold;
}
h1 class=’green bold’
What do we use to when we want to give an html element its own unique style?
large-title {
We use the id attribute.
h1 id=’large-title’ …./h1
Important note: Greater than/less than have been removed in code above.
}
How is the class attribute different than the id attribute?
The class attribute accepts multiple values and can be used broadly throughout an HTML document. The element’s id can only have a single value and can only be used once per page.
What is the attribute selector?
Attribute selectors allow you to create rules that apply to elements that have an attribute with a specific value.
What is one advantage of using the attribute selector compared to class or id?
When we use the attribute selector we do not need to write any new code (new html markup- id or class)
What are pseudo-class selectors?
Pseudo-class selectors allow you to change the appearance of elements when a user is interacting with them.
For example: When you’re filling out a form and the submit button is grayed out and disabled. But when all of the fields have been filled out, the button has color showing that it’s active.
:hover
This is applied when a user hovers over an element with a pointing device such as a mouse. Commonly used to change the appearance of links and buttons when a user places their cursor over them.
:active
Active is applied when an element is being activated by a user (a button being pressed or link being clicked). Makes the user “feel” like it is being pressed.
:focus
This is applied when an element has focus. Any element that you can interact with (link, form) can have focus. It is generally triggered when the user clicks or taps on an element or selects it with the keyboard’s tab key.
:visited
Visited represents links that the user has already visited. For privacy reasons, the styles that can be modified using this selector are very limited.