- HTML Document Structure:
An HTML document consists of several elements that work together to define the content and structure of a web page. The basic structure of an HTML document includes the following components:
<!DOCTYPE> declaration: This specifies the version of HTML being used (e.g., <!DOCTYPE html>).
<html> element: This acts as the root element and contains all other elements.
<head> element: This contains meta information about the HTML document, such as the title, character encoding, and external CSS or JavaScript files.
<title> element: This specifies the title of the HTML document, which is displayed in the browser's title bar or tab.
<body> element: This contains the visible content of the HTML document, including headings, paragraphs, images, links, forms, etc.
Additional elements can be nested within these basic components to structure and style the content further.
-
Steps to create an HTML document in Notepad and display it in a browser:
-
Open Notepad (or any text editor).
-
Begin with the <!DOCTYPE html> declaration to specify the HTML version.
-
Start the HTML document by adding the opening and closing <html> tags.
-
Inside the <html> tags, include the <head> and <body> sections.
-
Within the <head> section, add a <title> element and provide a title for the web page.
-
Within the <body> section, add the desired content using HTML elements and tags.
-
Save the file with a .html extension (e.g., index.html).
-
Open a web browser and navigate to the saved HTML file to see the output.
-
Example page with different types of headings:
<!DOCTYPE html>
<html>
<head>
<title>Headings Example</title>
</head>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</body>
</html>
- Example page with text formatting tags:
<!DOCTYPE html>
<html>
<head>
<title>Text Formatting Example</title>
</head>
<body>
<h1>Text Formatting Example</h1>
<p>This is a normal paragraph.</p>
<p><b>Bold text.</b></p>
<p><i>Italic text.</i></p>
<p><u>Underlined text.</u></p>
<p><s>Strikethrough text.</s></p>
<p>This text is <sup>superscripted</sup> and this text is <sub>subscripted</sub>.</p>
<p>This text is <mark>highlighted</mark>.</p>
<p>This text is <strong>strongly emphasized</strong>.</p>
<p>This text is <em>emphasized</em>.</p>
</body>
</html>
- Example page with different fonts and colors for Heading 1:
<!DOCTYPE html>
<html>
<head>
<title>Heading1 Fonts and Colors</title>
<style>
h1.font1 {
font-family: Arial, sans-serif;
color: red;
}
h1.font2 {
font-family: Verdana, sans-serif;
color: blue;
}
h1.font3 {
font-family: Times New Roman, serif;
color: green;
}
h1.font4 {
font-family: Impact, sans-serif;
color: orange;
}
h1.font5 {
font-family: Courier New, monospace;
color: purple;
}
</style>
</head>
<body>
<h1 class="font1">John Doe</h1>
<h1 class="font2">John Doe</h1>
<h1 class="font3">John Doe</h1>
<h1 class="font4">John Doe</h1>
<h1 class="font5">John Doe</h1>
</body>
</html>
- Example page with resume/portfolio design and picture:
<!DOCTYPE html>
<html>
<head>
<title>Resume/Portfolio Page</title>
<style>
body {
font-family: Arial, sans-serif;
}
h1 {
color: #333;
}
img {
width: 150px;
height: 150px;
border-radius: 50%;
}
</style>
</head>
<body>
<h1>John Doe</h1>
<img src="profile_picture.jpg" alt="Profile Picture">
<p>Summary: Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<h2>Education</h2>
<ul>
<li>Bachelor's Degree in Computer Science</li>
<li>XYZ University</li>
</ul>
<h2>Experience</h2>
<ul>
<li>Software Engineer, ABC Company</li>
<li>Web Developer, DEF Inc.</li>
</ul>
</body>
</html>
- Example page with class time table using the table tag:
<!DOCTYPE html>
<html>
<head>
<title>Class Time Table</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>Class Time Table</h1>
<table>
<tr>
<th>Day</th>
<th>Time</th>
<th>Subject</th>
</tr>
<tr>
<td>Monday</td>
<td>9:00 AM - 10:30 AM</td>
<td>Mathematics</td>
</tr>
<tr>
<td>Tuesday</td>
<td>11:00 AM - 12:30 PM</td>
<td>Science</td>
</tr>
<tr>
<td>Wednesday</td>
<td>2:00 PM - 3:30 PM</td>
<td>English</td>
</tr>
<tr>
<td>Thursday</td>
<td>9:00 AM - 10:30 AM</td>
<td>History</td>
</tr>
<tr>
<td>Friday</td>
<td>11:00 AM - 12:30 PM</td>
<td>Geography</td>
</tr>
</table>
</body>
</html>
- Example login form using HTML only:
<!DOCTYPE html>
<html>
<head>
<title>Login Form</title>
<style>
body {
font-family: Arial, sans-serif;
}
form {
max-width: 300px;
margin: 0 auto;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
</style>
</head>
<body>
<h1>Login Form</h1>
<form action="login.php" method="POST">
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
</body>
</html>
- Example feedback/registration form using various form elements:
<!DOCTYPE html>
<html>
<head>
<title>Feedback/Registration Form</title>
<style>
body {
font-family: Arial, sans-serif;
}
form {
max-width: 300px;
margin: 0 auto;
}
input[type="text"], input[type="email"], textarea {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
</style>
</head>
<body>
<h1>Feedback/Registration Form</h1>
<form action="submit.php" method="POST">
<label for="name">Name</label>
<input type="text" id="name" name="name" required>
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
<label for="rating">Rating</label>
<select id="rating" name="rating">
<option value="5">Excellent</option>
<option value="4">Good</option>
<option value="3">Average</option>
<option value="2">Poor</option>
<option value="1">Very Poor</option>
</select>
<label for="comments">Comments</label>
<textarea id="comments" name="comments" required></textarea>
<button type="submit">Submit</button>
</form>
</body>
</html>
- Example page using frames to display multiple pages in a single browser window:
<!DOCTYPE html>
<html>
<head>
<title>Frames Example</title>
</head>
<frameset cols="20%, 80%">
<frame src="resume.html">
<frameset rows="50%, 50%">
<frame src="table.html">
<frame src="login.html">
</frameset>
</frameset>
</html>