Web Lecture 1
Web Lecture 1
The <div> and <span> elements allow you to group together several elements to create
sections or subsections of a page.
Example
<!DOCTYPE html>
<html>
<head>
<style>
.container {
border: 1px solid black;
padding: 10px;
margin: 10px;
}
.header {
font-size: 24px;
font-weight: bold;
}
.content {
font-size: 16px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">Header Section</div>
<div class="content">
This is the content area within the div container.
</div>
</div>
</body>
</html>
Explanation: The <div> with the class container groups the header and content sections. The
container has a border and padding applied, while the header and content classes have their
own styles.
Example
<!DOCTYPE html>
<html>
<head>
<style>
.highlight {
background-color: yellow;
font-weight: bold;
}
</style>
</head>
<body>
<p>This is an example of using the <span class="highlight">span</span> element
to highlight a portion of text.</p>
</body>
</html>
Explanation: The <span> element with the class highlight is used to apply a background color
and bold text to just a portion of the text within the paragraph.
<ol>
<li>First Item</li>
<li>Second Item</li>
<li>Third Item</li>
</ol>
6.
7. HTML
HTML––LISTS
TABLES
1. <table>
Description: Defines the table structure.
Example:
<table border="1">
<!-- Table content goes here -->
</table>
2. <tr> (Table Row)
Description: Defines a row within a table.
Example:
<table border="1">
<tr>
<!-- Row content goes here -->
</tr>
</table>
<table border="1">
<tr>
<td>John</td>
<td>30</td>
</tr>
<tr>
<td>Sarah</td>
<td>25</td>
</tr>
</table>
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
</table>
6. <tbody> (Table Body)
Description: Defines the body content of the table. Typically contains the main data rows.
Example:
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>30</td>
</tr>
<tr>
<td>Sarah</td>
<td>25</td>
</tr>
</tbody>
</table>
8. <caption>
Description: Defines a title or caption for the table, displayed above the table by default.
Example:
<table border="1">
<caption>Person Information</caption>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>30</td>
</tr>
</table>