So friends, today we are going to make a simple website using Html, css and js.
HTML Code –
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Coding Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Navigation Bar -->
<nav>
<div class="logo">CodeMaster</div>
<ul class="nav-links">
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<!-- Hero Section -->
<section id="home" class="hero">
<h1>Welcome to CodeMaster</h1>
<p>Learn to code and build amazing projects!</p>
<button id="cta-button">Get Started</button>
</section>
<!-- About Section -->
<section id="about" class="about">
<h2>About Us</h2>
<p>We are a community of developers passionate about teaching and learning coding languages.</p>
</section>
<!-- Services Section -->
<section id="services" class="services">
<h2>Our Services</h2>
<div class="service-cards">
<div class="card">
<h3>Web Development</h3>
<p>Learn to build responsive and modern websites.</p>
</div>
<div class="card">
<h3>Mobile Apps</h3>
<p>Create cross-platform mobile applications.</p>
</div>
<div class="card">
<h3>Data Science</h3>
<p>Explore the world of data analysis and machine learning.</p>
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact" class="contact">
<h2>Contact Us</h2>
<form id="contact-form">
<input type="text" id="name" placeholder="Your Name" required>
<input type="email" id="email" placeholder="Your Email" required>
<textarea id="message" placeholder="Your Message" required></textarea>
<button type="submit">Send Message</button>
</form>
</section>
<!-- Footer -->
<footer>
<p>© 2023 CodeMaster. All rights reserved.</p>
</footer>
<script src="script.js"></script>
</body>
</html>
CSS Code –
/* styles.css */
/* General Styles */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
line-height: 1.6;
color: #333;
}
/* Navigation Bar */
nav {
display: flex;
justify-content: space-between;
align-items: center;
background: #333;
padding: 1rem 2rem;
}
nav .logo {
color: #fff;
font-size: 1.5rem;
font-weight: bold;
}
nav .nav-links {
list-style: none;
display: flex;
gap: 1rem;
}
nav .nav-links a {
color: #fff;
text-decoration: none;
}
nav .nav-links a:hover {
color: #f4c10f;
}
/* Hero Section */
.hero {
background: url('https://via.placeholder.com/1500') no-repeat center center/cover;
color: #fff;
text-align: center;
padding: 5rem 1rem;
}
.hero h1 {
font-size: 3rem;
margin-bottom: 1rem;
}
.hero p {
font-size: 1.2rem;
margin-bottom: 2rem;
}
.hero button {
background: #f4c10f;
border: none;
padding: 0.8rem 2rem;
font-size: 1rem;
cursor: pointer;
}
.hero button:hover {
background: #e0b10e;
}
/* About Section */
.about {
padding: 2rem;
text-align: center;
}
.about h2 {
margin-bottom: 1rem;
}
/* Services Section */
.services {
padding: 2rem;
text-align: center;
background: #f4f4f4;
}
.services h2 {
margin-bottom: 2rem;
}
.service-cards {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.card {
background: #fff;
padding: 1rem;
margin: 1rem;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
width: 30%;
}
.card h3 {
margin-bottom: 0.5rem;
}
/* Contact Section */
.contact {
padding: 2rem;
text-align: center;
}
.contact h2 {
margin-bottom: 1rem;
}
.contact form {
display: flex;
flex-direction: column;
align-items: center;
}
.contact input, .contact textarea {
width: 50%;
padding: 0.5rem;
margin: 0.5rem 0;
border: 1px solid #ccc;
border-radius: 5px;
}
.contact button {
background: #333;
color: #fff;
border: none;
padding: 0.8rem 2rem;
cursor: pointer;
}
.contact button:hover {
background: #444;
}
/* Footer */
footer {
background: #333;
color: #fff;
text-align: center;
padding: 1rem;
}
JS Code –
// script.js
// Add interactivity to the CTA button
document.getElementById('cta-button').addEventListener('click', function() {
alert('Welcome to CodeMaster! Let’s start coding.');
});
// Form submission handling
document.getElementById('contact-form').addEventListener('submit', function(event) {
event.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
if (name && email && message) {
alert(`Thank you, ${name}! Your message has been sent.`);
document.getElementById('contact-form').reset();
} else {
alert('Please fill out all fields.');
}
});
OutPut –