4. CSS Flashcards
What does CSS do?
Allows applying the same format to various elements in a web page.
What are 3 types of CSS?
- External
- Internal
- Inline CSS
CSS structure?
Selector {property:value; property:value; …property:value}
How to make paragraph text black and 10 pixels large?
P {color:black; font-size:10px;}
What does a selector do?
A selector allows choosing the specific element of interest that needs styling.
Types of selectors? (3)
- Element selector
- Id selector
- Class selector
What is an element selector?
Selecting based on element name
ex:
p {
text-align: center;
color: red;
}→css applies to all <p></p> tags
What is a Id selector?
para1 {
Selecting based on the id of the element
ex:
text-align: center;
color: red;
}→ css applies to the HTML element with id=“para1” attribute
What is a class selector?
Selecting based on the class of the element
ex:
.center {
text-align: center;
color: red;
}→ css applies to the HTML elements with class=“center” attribute
What are styles used in this course? (7)
- Font
- Background
- Border
- Margin
- Padding
- Height
- Width
What does CSS mean?
Cascading Style Sheets
What is id? (2)
- A unique identifier, therefore, each specific id can only be assigned to one element in an HMTL page
- Used to target a single element
What is class used for? (2)
- Class is used for grouping elements together.
- Several elements can have the same class name
Where are class and id defined?
Inside a tag (e.g., <p class=“class1” id=“para2”>…</p>)
CSS commment structure
/* This is a single-line comment */