What does CSS do?
Allows applying the same format to various elements in a web page.
What are 3 types of 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)
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)
What does CSS mean?
Cascading Style Sheets
What is id? (2)
What is class used for? (2)
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 */
HTML comment structure?
<!-- These paragraphs will be red -->
3 useful properties to define colours
Basic Styles-Background properties (2)?
ex background-image:
body {background-image: url(“paper.gif”);}
Border styles proporties? (10)
Other border properties
Border-width: 5px; -> other values: medium, thick, etc.
Border-color: red;
Define margins in 4 directions
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
Basic styles height and width
Adding external CSS
Each HTML page must include a reference to the external style sheet file inside the <link></link> element, inside the head section.
<link></link>
Defining internal CSS
The internal style is defined inside the <style> element, inside the head section.</style>