-
Notifications
You must be signed in to change notification settings - Fork 0
Session 3 HTML and CSS
In this session, we'll learn how to create and style web pages using HTML (HyperText Markup Language) and CSS (Cascading Style Sheets). HTML provides the structure of a webpage, while CSS controls its appearance and layout.
- Understand the basic structure of an HTML document
- Learn essential HTML elements and their purposes
- Understand CSS selectors and properties
- Apply styles to HTML elements
- Create responsive designs
HTML (HyperText Markup Language) is the standard markup language for documents designed to be displayed in a web browser. It defines the structure and content of web pages.
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first web page.</p>
</body>
</html>- Headings:
<h1>to<h6> - Paragraphs:
<p> - Lists:
<ul>,<ol>,<li> - Text formatting:
<strong>,<em>,<span>
<h1>This is a Heading 1</h1>
<h2>This is a Heading 2</h2>
<p>This is a paragraph with <strong>bold</strong> and <em>italic</em> text.</p>
<ul>
<li>Unordered list item 1</li>
<li>Unordered list item 2</li>
</ul>
<ol>
<li>Ordered list item 1</li>
<li>Ordered list item 2</li>
</ol>- Links:
<a href="url">link text</a> - Images:
<img src="image.jpg" alt="description">
<a href="https://www.example.com">Visit Example.com</a>
<img src="cat.jpg" alt="A cute cat">- Containers:
<div>,<section>,<article> - Navigation:
<nav> - Header and Footer:
<header>,<footer>
<div class="container">
<header>
<nav>
<a href="index.html">Home</a>
<a href="about.html">About</a>
</nav>
</header>
<section>
<h2>Section Title</h2>
<p>Section content goes here.</p>
</section>
<footer>
<p>© 2025 My Website</p>
</footer>
</div>CSS (Cascading Style Sheets) is used to control the visual presentation of HTML elements. It allows you to define styles for your web pages including layouts, colors, fonts, and more.
- Inline CSS: Using the
styleattribute - Internal CSS: Using the
<style>tag in the<head>section - External CSS: Linking to an external CSS file using the
<link>tag
<!-- External CSS -->
<head>
<link rel="stylesheet" href="styles.css">
</head>
<!-- Internal CSS -->
<head>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
</style>
</head>
<!-- Inline CSS -->
<p style="color: blue; font-size: 18px;">This is a paragraph with inline styles.</p>CSS selectors define which HTML elements you want to style.
/* Element selector */
h1 {
color: blue;
}
/* Class selector */
.highlight {
background-color: yellow;
}
/* ID selector */
#header {
height: 100px;
}
/* Descendant selector */
nav a {
text-decoration: none;
}
/* Pseudo-class selector */
a:hover {
color: red;
}CSS properties define the styles you want to apply to the selected elements.
/* Text properties */
p {
font-family: Arial, sans-serif;
font-size: 16px;
color: #333333;
line-height: 1.5;
text-align: justify;
}
/* Box model properties */
.box {
width: 300px;
height: 200px;
padding: 20px;
margin: 10px;
border: 1px solid black;
}
/* Background properties */
body {
background-color: #f5f5f5;
background-image: url('background.jpg');
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}Responsive design ensures that your website looks good on all devices.
/* Media queries */
@media (max-width: 768px) {
.container {
width: 100%;
padding: 0 15px;
}
h1 {
font-size: 24px;
}
}
/* Flexbox */
.flex-container {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
/* CSS Grid */
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
}- Create a simple personal webpage with HTML
- Style your webpage using CSS
- Make your webpage responsive for mobile devices
- Create a navigation menu with links
- Build a simple photo gallery
Now that you know how to create and style web pages, you're ready to move on to Session 4: JavaScript Basics where you'll learn how to add interactivity to your web pages.