CSS Flashcards
When is internal css styling useful?
Internal css styling is useful when applying styles to one html document.
Example:
<style>
html { background: red; }</style>
When is inline css useful?
Inline css is useful when adding css styling to a single element on your html page. Not good for adding styling to several elements.
What are the three ways to add css to an html website?
- Inline
<tag></tag>
- Internal
<style>
css</style>
- External
<link></link>
What does CSS stand for?
Cascading Styles Sheets
What are named colors?
The <named-color> CSS data type is the name of a color, such as red, blue, black, or lightseagreen.</named-color>
Example:
color: rebeccapurple;
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)
A declaration is what we call the property and value that we want to add to an element. The property is what we want to change and the value is how we want to change it.
p {
color: blue;
}
The declaration = color: blue;
What is a property? (Ruleset)
A property specifies 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. It is an attribute available to all elements (global attribute).
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 are four ways we can represent font size in css?
Pixels, points, em (pronounced “m”), rem.
How is 1em defined?
1 em is defined as the full width of the letter M. In practical terms, 1 em is going to be 100 percent of the parent size.
If the parent element is 20px than 1em would be 20px. If the parent element is 20px, a child element set to 2 em would be 40 px (twice as much).
How is rem different from em?
rem is a relative size just like em but instead of being relative to the parent it is relative to the root of your html file (which is usually an html element).
When we are setting the font size should we use rem or em and why?
It’s recommended to use rem because when you have different elements embedded in others it can become difficult to identify the parent elements.
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.
}
Drag Me