HTML (Hypertext Markup Language) is the backbone of any web page. For a one - long page website, we use HTML to structure different sections of content. Each section can represent a different topic or a stage in a narrative.
The basic building blocks include <html>
, <head>
, and <body>
tags. Inside the <body>
, we use semantic tags like <header>
, <main>
, <section>
, and <footer>
to organize the content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF - 8">
<meta name="viewport" content="width=device - width, initial - scale=1.0">
<title>One - Long Page Website</title>
</head>
<body>
<header>
<h1>My One - Long Page Site</h1>
</header>
<main>
<section id="section1">
<h2>Section 1</h2>
<p>Content of section 1 goes here.</p>
</section>
<section id="section2">
<h2>Section 2</h2>
<p>Content of section 2 goes here.</p>
</section>
</main>
<footer>
<p>© 2024 My One - Long Page Site</p>
</footer>
</body>
</html>
CSS (Cascading Style Sheets) is used to style the HTML elements. We can control the layout, colors, fonts, and spacing of different sections.
We can use internal CSS (within the <style>
tag in the <head>
) or external CSS (by linking an external .css
file).
/* External CSS example */
body {
font-family: Arial, sans - serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: white;
text-align: center;
padding: 20px;
}
section {
padding: 50px;
border-bottom: 1px solid #ccc;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
}
<!DOCTYPE html>
to tell the browser that it is an HTML5 document.<html>
, <head>
, and <body>
tags.<header>
, <main>
, <section>
, and <footer>
to divide the content into logical parts. Each section can have a unique id
for easy referencing.color
, font - size
, margin
).<section>
to clearly define different sections of content. This improves accessibility and makes the code more readable.<a>
).<nav>
<ul>
<li><a href="#section1">Section 1</a></li>
<li><a href="#section2">Section 2</a></li>
</ul>
</nav>
<html>
tag to enable smooth scrolling when clicking on anchor links.html {
scroll - behavior: smooth;
}
@media (max - width: 768px) {
section {
padding: 20px;
}
}
Creating a one - long page website using HTML and CSS is a rewarding task. By understanding the fundamental concepts, using the right usage methods, following common practices, and implementing best practices, you can build a visually appealing and user - friendly single - long page website. These websites offer a great way to present information in a linear and engaging manner.