CSS in Depth Notes With Project
CSS in Depth Notes With Project
1. Introduction to CSS
CSS is a style sheet language used to describe the presentation of a web page.
Example:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<h1>Welcome!</h1>
</body>
</html>
CSS (style.css):
h1 {
color: blue;
text-align: center;
p {
font-size: 16px;
color: gray;
}
Example:
HTML:
CSS:
.text {
color: green;
font-weight: bold;
Selectors:
Advanced Example:
HTML:
<ul>
<li>Home</li>
<li>About</li>
</ul>
CSS:
ul li:nth-child(2) {
color: red;
Example:
HTML:
CSS:
.box {
width: 100px;
height: 100px;
padding: 10px;
margin: 20px;
background-color: lightblue;
4. Flexbox Layout
Example:
HTML:
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
CSS:
.container {
display: flex;
justify-content: space-around;
align-items: center;
height: 100px;
.item {
background-color: coral;
padding: 20px;
color: white;
We will create a responsive webpage with a navigation bar, hero section, and footer.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<nav>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<section class="hero">
<h1>Welcome to My Website</h1>
</section>
<footer>
</footer>
</body>
</html>
CSS:
nav {
background-color: #333;
padding: 10px;
nav ul {
display: flex;
justify-content: center;
list-style: none;
nav ul li {
margin: 0 15px;
color: white;
.hero {
text-align: center;
background-color: lightgray;
padding: 50px 0;
footer {
text-align: center;
padding: 10px;
background-color: #333;
color: white;