What is CSS? Itroduction of CCS
CSS
What is CSS?
- CSS stands for Cascading Stylesheet.
- CSS is a stylesheet language use to describe the presentation of an HTML document.
- CSS describes how element should be rendered on screen.
CSS Prerequisites
Why use CSS
CSS Example
body{
background-color: gray;
}
p{
font-size: 20px;
color: gold;
}
CSS Syntax
div{
background-color: black;
width: 200px;
height: 200px;
div{
background-color: black;
width: 200px;
height: 200px;
The declaration block are grouped in block. Each declaration block contains CSS declaration which are wrapped by an opening curly brace { and a closing curly brace } .
div{
background-color: black;
width: 200px;
height: 200px;
CSS declaration or declarations are contained inside a declaration block. Each declaration has to be separated by a semicolon ; otherwise the codes don’t work. It is permitted not to put a semicolon int the last assertion.
div{
background-color :black;
width: 200px;
height: 200px;
A CSS statement is made out of a couple of a property and a worth separated by a colon.
background-color : black;
property the colon that separates the two entities value
- Property: human-readable identifier that indicates which stylistic feature to change.
- Value: it is given to a property which indicates how the specified stylistic feature should be changed.
CSS Selectors
Element Selectors
Example:
h1{
font-weight: bold;
}
p{
color: green;
}
Class Selector
CSS class selector are very useful when targeting different elements.
The class selector consider of a dot ( . ) followed by a class name.
A class name is defined using the class attribute.
Example:
.underlined-text{
text-decoration: underline;
}
.emboldened-text{
font-weight: bold;
}
ID Selectors
Example:
#blue {
background-color: blue;
Width: 200px;
height : 200px;
}
#red {
background-color: red;
width:200px;
height: 200px;
}
Example:
p .red{
color: red;
}
p #green{
color: green;
}
Grouping Selector
Example:
h1{
font-family: Time New Roman;
color: green;
}
p{
font-family: Time New Roman;
color: green;
}
Example:
h1, p{
font-family: Time New Roman;
color: green;
}
CSS Comments
Example:
p{
color: fuchsia;
/* a single line CSS comment */
}
/* a multi-line comment
cause we love CSS nut we
might still forger what some codes */
CSS Inserting
There are three simple ways to insert CSS int an HTML document.
- Internal Style Sheet
- External Style Sheet
- Inline Styling
Internal Style Sheet is useful when a single HTML document has its unique styles.
Example:
<!DOCTYPE htmlp>
<html>
<head>
<title>PoorWebDev</title>
<link rel="stylesheet" href="style.css">
<style type="text/css">
p {
color: red;
}
</style>
</head>
<body>
<h1>This is a header </h1>
<p>This is a paragraph</p>
<body>
<html>
External Style Sheet
body{
background: blue;
}
p{
color: red;
}
Now that we have our external style sheet file. The following stage is to include it for your HTML page.
We can basically do by characterizing its record way utilizing the <link> element with its href attribute.
<!DOCTYPE htmlp>
<html>
<head>
<title>PoorWebDev</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>This is a header </h1>
<p>This is a paragraph</p>
<body>
<html>
Inline Styling
Inline styling is helpful for styling a solitary component.
It is done by using the style attribute.
Its value contains CSS declarations.
<!DOCTYPE htmlp>
<html>
<head>
<title>PoorWebDev</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p style="color:aquamarine;">i love Poorwebdev</p>
<h1>This is a header </h1>
<p>This is a paragraph</p>
<body>
<html>