My Blog

My WordPress Blog

My Blog

My WordPress Blog

Book Review Site

Basic Structure

  1. HTML: Create a structure for your book reviews.
  2. CSS: Style the site to make it visually appealing.
  3. JavaScript: Add interactivity, such as adding and displaying reviews.

Step 1: HTML

<!DOCTYPE html>
<html lang="en">
<head>
&lt;meta charset="UTF-8">
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
&lt;title>Book Review Site&lt;/title>
&lt;link rel="stylesheet" href="styles.css">
</head> <body>
&lt;div class="container">
    &lt;h1>Book Review Site&lt;/h1>
    &lt;form id="reviewForm">
        &lt;input type="text" id="bookTitle" placeholder="Book Title" required>
        &lt;textarea id="bookReview" placeholder="Write your review here..." required>&lt;/textarea>
        &lt;button type="submit">Submit Review&lt;/button>
    &lt;/form>
    &lt;div id="reviewsContainer">
        &lt;h2>Reviews:&lt;/h2>
        &lt;ul id="reviewsList">&lt;/ul>
    &lt;/div>
&lt;/div>
&lt;script src="script.js">&lt;/script>
</body> </html>

Step 2: CSS

Create a file named styles.css to style your site.

body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
} .container {
max-width: 600px;
margin: auto;
background: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
} h1, h2 {
color: #333;
} form {
margin-bottom: 20px;
} input[type="text"], textarea {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 4px;
} button {
background-color: #28a745;
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
} button:hover {
background-color: #218838;
} #reviewsList {
list-style-type: none;
padding: 0;
} .review {
background: #f9f9f9;
padding: 10px;
margin: 5px 0;
border-radius: 4px;
}

Step 3: JavaScript

Create a file named script.js to handle the review submissions and display.

document.getElementById('reviewForm').addEventListener('submit', function(event) {
event.preventDefault();
const bookTitle = document.getElementById('bookTitle').value;
const bookReview = document.getElementById('bookReview').value;
const reviewList = document.getElementById('reviewsList');
const reviewItem = document.createElement('li');
reviewItem.classList.add('review');
reviewItem.innerHTML = &amp;lt;strong&gt;${bookTitle}&amp;lt;/strong&gt;&amp;lt;p&gt;${bookReview}&amp;lt;/p&gt;;
reviewList.appendChild(reviewItem);
// Clear the form
document.getElementById('reviewForm').reset();
});

Putting It All Together

  1. Folder Structure:
    • Create a folder for your project.
    • Inside that folder, create three files: index.html, styles.css, and script.js.
  2. Open the HTML: Open index.html in your web browser to see your book review site in action!

Future Enhancements

  • Backend Integration: Use a backend service to store reviews permanently.
  • User Authentication: Allow users to create accounts and save their reviews.
  • Rating System: Implement a star rating system for reviews.
  • Search Functionality: Enable searching for books and reviews.
Book Review Site

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top