Blog Layout Project
Create a professional blog layout with articles, sidebar, categories, and comment sections.
📋 Project Overview
- Objective: Build a complete blog website
- Sections: Articles, sidebar, categories, comments
- Features: Search, tags, author info, pagination
- Focus: Content readability and organization
💻 Complete Blog HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="TechBlog - Web Development Insights">
<title>TechBlog - Web Development & Programming</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Georgia, 'Times New Roman', serif;
line-height: 1.8;
color: #333;
background: #f8f9fa;
}
/* Header */
header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 2rem;
text-align: center;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
header h1 {
font-size: 3rem;
margin-bottom: 0.5rem;
}
header p {
font-size: 1.2rem;
opacity: 0.9;
}
/* Navigation */
nav {
background: white;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
position: sticky;
top: 0;
z-index: 100;
}
nav ul {
list-style: none;
display: flex;
justify-content: center;
gap: 2rem;
padding: 1rem;
}
nav a {
text-decoration: none;
color: #333;
font-weight: 500;
transition: color 0.3s;
}
nav a:hover {
color: #667eea;
}
/* Main Container */
.container {
max-width: 1200px;
margin: 2rem auto;
display: grid;
grid-template-columns: 2fr 1fr;
gap: 2rem;
padding: 0 2rem;
}
/* Articles */
.articles {
display: flex;
flex-direction: column;
gap: 2rem;
}
article {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
transition: transform 0.3s;
}
article:hover {
transform: translateY(-5px);
}
.article-image {
width: 100%;
height: 300px;
object-fit: cover;
}
.article-content {
padding: 2rem;
}
.article-meta {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
font-size: 0.9rem;
color: #7f8c8d;
}
.article-meta span {
display: flex;
align-items: center;
gap: 0.3rem;
}
article h2 {
font-size: 2rem;
margin-bottom: 1rem;
color: #2c3e50;
}
article h2 a {
text-decoration: none;
color: inherit;
transition: color 0.3s;
}
article h2 a:hover {
color: #667eea;
}
.article-excerpt {
margin-bottom: 1rem;
color: #555;
}
.article-tags {
display: flex;
gap: 0.5rem;
margin-bottom: 1rem;
}
.tag {
background: #ecf0f1;
padding: 0.3rem 0.8rem;
border-radius: 15px;
font-size: 0.85rem;
text-decoration: none;
color: #555;
transition: background 0.3s;
}
.tag:hover {
background: #667eea;
color: white;
}
.read-more {
display: inline-block;
color: #667eea;
text-decoration: none;
font-weight: bold;
transition: color 0.3s;
}
.read-more:hover {
color: #764ba2;
}
/* Sidebar */
aside {
display: flex;
flex-direction: column;
gap: 2rem;
}
.sidebar-widget {
background: white;
padding: 1.5rem;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.sidebar-widget h3 {
margin-bottom: 1rem;
color: #2c3e50;
border-bottom: 2px solid #667eea;
padding-bottom: 0.5rem;
}
/* Search Widget */
.search-form {
display: flex;
gap: 0.5rem;
}
.search-form input {
flex: 1;
padding: 0.8rem;
border: 2px solid #ecf0f1;
border-radius: 5px;
}
.search-form button {
padding: 0.8rem 1.5rem;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s;
}
.search-form button:hover {
background: #764ba2;
}
/* Categories Widget */
.categories-list {
list-style: none;
}
.categories-list li {
padding: 0.5rem 0;
border-bottom: 1px solid #ecf0f1;
}
.categories-list a {
text-decoration: none;
color: #555;
display: flex;
justify-content: space-between;
transition: color 0.3s;
}
.categories-list a:hover {
color: #667eea;
}
.post-count {
background: #ecf0f1;
padding: 0.2rem 0.6rem;
border-radius: 10px;
font-size: 0.85rem;
}
/* Popular Posts Widget */
.popular-posts {
list-style: none;
}
.popular-post {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
padding-bottom: 1rem;
border-bottom: 1px solid #ecf0f1;
}
.popular-post:last-child {
border-bottom: none;
}
.popular-post-image {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 5px;
}
.popular-post-info h4 {
margin-bottom: 0.3rem;
font-size: 0.95rem;
}
.popular-post-info a {
text-decoration: none;
color: #333;
transition: color 0.3s;
}
.popular-post-info a:hover {
color: #667eea;
}
.popular-post-date {
font-size: 0.8rem;
color: #7f8c8d;
}
/* Tags Cloud Widget */
.tags-cloud {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
/* Newsletter Widget */
.newsletter-form {
display: flex;
flex-direction: column;
gap: 1rem;
}
.newsletter-form input {
padding: 0.8rem;
border: 2px solid #ecf0f1;
border-radius: 5px;
}
.newsletter-form button {
padding: 0.8rem;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s;
}
.newsletter-form button:hover {
background: #764ba2;
}
/* Pagination */
.pagination {
display: flex;
justify-content: center;
gap: 0.5rem;
margin: 2rem 0;
}
.pagination a,
.pagination span {
padding: 0.8rem 1.2rem;
background: white;
border-radius: 5px;
text-decoration: none;
color: #333;
transition: all 0.3s;
}
.pagination a:hover {
background: #667eea;
color: white;
}
.pagination .current {
background: #667eea;
color: white;
}
/* Comments Section */
.comments-section {
background: white;
padding: 2rem;
border-radius: 10px;
margin-top: 2rem;
}
.comments-section h3 {
margin-bottom: 1.5rem;
color: #2c3e50;
}
.comment {
display: flex;
gap: 1rem;
margin-bottom: 1.5rem;
padding-bottom: 1.5rem;
border-bottom: 1px solid #ecf0f1;
}
.comment:last-child {
border-bottom: none;
}
.comment-avatar {
width: 50px;
height: 50px;
border-radius: 50%;
}
.comment-content {
flex: 1;
}
.comment-author {
font-weight: bold;
margin-bottom: 0.3rem;
}
.comment-date {
font-size: 0.85rem;
color: #7f8c8d;
margin-bottom: 0.5rem;
}
.comment-reply {
margin-top: 0.5rem;
}
.comment-reply a {
color: #667eea;
text-decoration: none;
font-size: 0.9rem;
}
/* Comment Form */
.comment-form {
margin-top: 2rem;
}
.comment-form h4 {
margin-bottom: 1rem;
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: bold;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 0.8rem;
border: 2px solid #ecf0f1;
border-radius: 5px;
}
.form-group textarea {
resize: vertical;
min-height: 120px;
}
.submit-btn {
padding: 0.8rem 2rem;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s;
}
.submit-btn:hover {
background: #764ba2;
}
/* Footer */
footer {
background: #2c3e50;
color: white;
padding: 2rem;
text-align: center;
margin-top: 3rem;
}
/* Responsive */
@media (max-width: 768px) {
.container {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<!-- Header -->
<header>
<h1>📝 TechBlog</h1>
<p>Insights on Web Development & Programming</p>
</header>
<!-- Navigation -->
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Categories</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<!-- Main Container -->
<div class="container">
<!-- Articles -->
<main class="articles">
<article>
<img src="article1.jpg" alt="Modern web development" class="article-image">
<div class="article-content">
<div class="article-meta">
<span>📅 January 15, 2025</span>
<span>👤 By John Doe</span>
<span>💬 12 Comments</span>
</div>
<h2><a href="#">Getting Started with Modern Web Development</a></h2>
<div class="article-tags">
<a href="#" class="tag">HTML</a>
<a href="#" class="tag">CSS</a>
<a href="#" class="tag">JavaScript</a>
</div>
<p class="article-excerpt">
Learn the fundamentals of modern web development. This comprehensive guide covers HTML5, CSS3, and JavaScript ES6+ features that every developer should know. We'll explore semantic markup, responsive design principles, and modern JavaScript techniques.
</p>
<a href="#" class="read-more">Read More →</a>
</div>
</article>
<article>
<img src="article2.jpg" alt="React components" class="article-image">
<div class="article-content">
<div class="article-meta">
<span>📅 January 12, 2025</span>
<span>👤 By Jane Smith</span>
<span>💬 8 Comments</span>
</div>
<h2><a href="#">Building Reusable React Components</a></h2>
<div class="article-tags">
<a href="#" class="tag">React</a>
<a href="#" class="tag">JavaScript</a>
</div>
<p class="article-excerpt">
Discover best practices for creating reusable React components. Learn about component composition, props patterns, and how to build a scalable component library for your applications.
</p>
<a href="#" class="read-more">Read More →</a>
</div>
</article>
<article>
<img src="article3.jpg" alt="CSS Grid layout" class="article-image">
<div class="article-content">
<div class="article-meta">
<span>📅 January 10, 2025</span>
<span>👤 By Mike Johnson</span>
<span>💬 15 Comments</span>
</div>
<h2><a href="#">Mastering CSS Grid Layout</a></h2>
<div class="article-tags">
<a href="#" class="tag">CSS</a>
<a href="#" class="tag">Layout</a>
</div>
<p class="article-excerpt">
CSS Grid has revolutionized web layouts. In this tutorial, we'll dive deep into Grid properties, practical examples, and real-world use cases for building complex layouts with ease.
</p>
<a href="#" class="read-more">Read More →</a>
</div>
</article>
<!-- Pagination -->
<div class="pagination">
<a href="#">← Previous</a>
<span class="current">1</span>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">Next →</a>
</div>
</main>
<!-- Sidebar -->
<aside>
<!-- Search Widget -->
<div class="sidebar-widget">
<h3>🔍 Search</h3>
<form class="search-form">
<input type="search" placeholder="Search articles...">
<button type="submit">Go</button>
</form>
</div>
<!-- Categories Widget -->
<div class="sidebar-widget">
<h3>📂 Categories</h3>
<ul class="categories-list">
<li><a href="#">Web Development <span class="post-count">24</span></a></li>
<li><a href="#">JavaScript <span class="post-count">18</span></a></li>
<li><a href="#">CSS <span class="post-count">15</span></a></li>
<li><a href="#">React <span class="post-count">12</span></a></li>
<li><a href="#">Node.js <span class="post-count">10</span></a></li>
<li><a href="#">Tutorials <span class="post-count">32</span></a></li>
</ul>
</div>
<!-- Popular Posts Widget -->
<div class="sidebar-widget">
<h3>🔥 Popular Posts</h3>
<ul class="popular-posts">
<li class="popular-post">
<img src="thumb1.jpg" alt="Post thumbnail" class="popular-post-image">
<div class="popular-post-info">
<h4><a href="#">10 JavaScript Tips</a></h4>
<div class="popular-post-date">Jan 14, 2025</div>
</div>
</li>
<li class="popular-post">
<img src="thumb2.jpg" alt="Post thumbnail" class="popular-post-image">
<div class="popular-post-info">
<h4><a href="#">Flexbox vs Grid</a></h4>
<div class="popular-post-date">Jan 11, 2025</div>
</div>
</li>
<li class="popular-post">
<img src="thumb3.jpg" alt="Post thumbnail" class="popular-post-image">
<div class="popular-post-info">
<h4><a href="#">React Hooks Guide</a></h4>
<div class="popular-post-date">Jan 8, 2025</div>
</div>
</li>
</ul>
</div>
<!-- Tags Cloud Widget -->
<div class="sidebar-widget">
<h3>🏷️ Tags</h3>
<div class="tags-cloud">
<a href="#" class="tag">HTML5</a>
<a href="#" class="tag">CSS3</a>
<a href="#" class="tag">JavaScript</a>
<a href="#" class="tag">React</a>
<a href="#" class="tag">Node.js</a>
<a href="#" class="tag">Tutorial</a>
<a href="#" class="tag">Responsive</a>
<a href="#" class="tag">API</a>
</div>
</div>
<!-- Newsletter Widget -->
<div class="sidebar-widget">
<h3>📧 Newsletter</h3>
<p style="margin-bottom: 1rem; font-size: 0.95rem;">Subscribe to get the latest posts delivered to your inbox.</p>
<form class="newsletter-form">
<input type="email" placeholder="Your email" required>
<button type="submit">Subscribe</button>
</form>
</div>
</aside>
</div>
<!-- Comments Section (for single article page) -->
<!-- Uncomment for article detail page -->
<!--
<section class="comments-section" style="max-width: 800px; margin: 0 auto;">
<h3>💬 Comments (3)</h3>
<div class="comment">
<img src="avatar1.jpg" alt="User avatar" class="comment-avatar">
<div class="comment-content">
<div class="comment-author">Sarah Johnson</div>
<div class="comment-date">January 15, 2025 at 10:30 AM</div>
<p>Great article! This really helped me understand CSS Grid better. Looking forward to more content like this.</p>
<div class="comment-reply">
<a href="#">Reply</a>
</div>
</div>
</div>
<div class="comment">
<img src="avatar2.jpg" alt="User avatar" class="comment-avatar">
<div class="comment-content">
<div class="comment-author">Mike Chen</div>
<div class="comment-date">January 15, 2025 at 2:15 PM</div>
<p>Could you cover more advanced Grid techniques in a future post?</p>
<div class="comment-reply">
<a href="#">Reply</a>
</div>
</div>
</div>
<div class="comment-form">
<h4>Leave a Comment</h4>
<form>
<div class="form-group">
<label for="name">Name*</label>
<input type="text" id="name" required>
</div>
<div class="form-group">
<label for="email">Email*</label>
<input type="email" id="email" required>
</div>
<div class="form-group">
<label for="comment">Comment*</label>
<textarea id="comment" required></textarea>
</div>
<button type="submit" class="submit-btn">Post Comment</button>
</form>
</div>
</section>
-->
<!-- Footer -->
<footer>
<p>© 2025 TechBlog. All rights reserved.</p>
</footer>
</body>
</html>
🎯 Key Features
- Article grid: Featured images and excerpts
- Sidebar widgets: Search, categories, popular posts
- Meta information: Date, author, comment count
- Tag system: Article categorization
- Pagination: Navigate between pages
- Comments section: User engagement
- Newsletter signup: Build audience
- Responsive layout: Mobile-friendly design