Front-End Development Prompt
Design and develop a fully responsive website with HTML, CSS, and JavaScript. The site will have a clean, modern layout and contain the following pages:
Homepage:
A hero section with a large background image and a welcoming tagline.
Navigation bar with links to other pages (Home, About, Services, Blog, Contact).
Featured services section displaying 3 main services with brief descriptions and icons.
Latest blog posts preview section showing 3 recent articles with clickable titles and short summaries.
A call-to-action (CTA) section encouraging visitors to contact or sign up.
A footer with social media links, copyright info, and quick links to other pages.
About Page:
An introduction section with a profile picture or team photo.
Mission statement and company history sections.
A team members section displaying images and short bios of team members in a grid layout.
Services Page:
Display of available services using cards with images, descriptions, and “Learn More” buttons.
Each card should feature hover animations.
Blog Page:
A grid or list layout of blog posts showing the title, date, and featured image.
Pagination at the bottom for easy navigation through older posts.
Contact Page:
A contact form with fields for Name, Email, Subject, and Message.
Include basic form validation with JavaScript.
An embedded Google Maps section showing the business location.
Additional Requirements:
Fully responsive design, ensuring the site looks good on mobile, tablet, and desktop screens.
Smooth scrolling for page navigation links.
Use CSS animations to add subtle interactivity (e.g., hover effects, fade-ins).
JavaScript will handle the form validation and smooth scroll behavior.
Implement a sticky navigation bar that stays at the top of the screen when scrolling.
No back-end development required.
Assistant
Creating a fully responsive, multi-page website with HTML, CSS, and JavaScript involves several steps. Below is a comprehensive guide to help you design and develop the website as per your specifications. We'll break down the process into manageable sections, providing code snippets and explanations for each part.
Display previews of the three most recent blog articles.
html
<!-- index.html -->
<section class="latest-blog container">
<h2>Latest Blog Posts</h2>
<div class="grid grid-3">
<div class="blog-post">
<img src="images/blog1.jpg" alt="Blog Post 1">
<h3><a href="blog-post1.html">Understanding Front-End Development</a></h3>
<p>Learn the basics of front-end development and how to get started.</p>
</div>
<div class="blog-post">
<img src="images/blog2.jpg" alt="Blog Post 2">
<h3><a href="blog-post2.html">Responsive Design Tips</a></h3>
<p>Best practices for creating responsive and mobile-friendly websites.</p>
</div>
<div class="blog-post">
<img src="images/blog3.jpg" alt="Blog Post 3">
<h3><a href="blog-post3.html">JavaScript for Beginners</a></h3>
<p>A beginner's guide to understanding and using JavaScript effectively.</p>
</div>
</div>
</section>
<!-- index.html -->
<section class="cta-section">
<div class="container">
<h2>Ready to Take Your Business to the Next Level?</h2>
<p>Contact us today to learn how we can help you achieve your goals.</p>
<a href="contact.html" class="cta-button">Contact Us</a>
</div>
</section>
Provide company information, mission, history, and team members.
html
<!-- about.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About - Your Company</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<!-- Include Navigation Bar -->
<header>
<!-- [Navigation Bar Code as Above] -->
</header>
<!-- Introduction Section -->
<section class="about-intro container">
<img src="images/team-photo.jpg" alt="Team Photo" class="profile-img">
<div class="intro-text">
<h1>About Us</h1>
<p>Welcome to Your Company. We are dedicated to delivering the best services to our clients.</p>
</div>
</section>
<!-- Mission Statement -->
<section class="mission container">
<h2>Our Mission</h2>
<p>To provide innovative solutions that drive success and foster growth for our clients.</p>
</section>
<!-- Company History -->
<section class="history container">
<h2>Our History</h2>
<p>Founded in 2010, Your Company has grown from a small startup to a leading provider in the industry.</p>
</section>
<!-- Team Members -->
<section class="team container">
<h2>Meet the Team</h2>
<div class="grid grid-3">
<div class="team-member">
<img src="images/team1.jpg" alt="Team Member 1">
<h3>Jane Doe</h3>
<p>CEO</p>
</div>
<div class="team-member">
<img src="images/team2.jpg" alt="Team Member 2">
<h3>John Smith</h3>
<p>CTO</p>
</div>
<div class="team-member">
<img src="images/team3.jpg" alt="Team Member 3">
<h3>Emily Johnson</h3>
<p>Lead Designer</p>
</div>
<!-- Add more team members as needed -->
</div>
</section>
<!-- Footer -->
<footer>
<!-- [Footer Code as Above] -->
</footer>
<script src="js/scripts.js"></script>
</body>
</html>
Note: For actual pagination, you'd typically need back-end support or use JavaScript to fetch and display posts dynamically. Since back-end development is not required, you can create multiple blog pages (e.g., blog.html, blog-page2.html, etc.) and link them accordingly.
Contact Page
Include a contact form with validation and an embedded Google Map.
Important: Replace [YOUR_GOOGLE_MAPS_EMBED_LINK] with the actual embed link from Google Maps for your business location.
JavaScript Functionality
Implement smooth scrolling and form validation.
javascript
// scripts.js
// Smooth Scrolling
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetID = this.getAttribute('href').substring(1);
const target = document.getElementById(targetID);
if (target) {
window.scrollTo({
top: target.offsetTop - 70, // Adjust for navbar height
behavior: 'smooth'
});
}
});
});
// Form Validation
document.getElementById('contactForm').addEventListener('submit', function(e) {
e.preventDefault();
let isValid = true;
// Clear previous errors
document.querySelectorAll('.error-message').forEach(el => {
el.style.display = 'none';
el.textContent = '';
});
// Validate Name
const name = document.getElementById('name');
if (name.value.trim() === '') {
showError(name, 'Name is required.');
isValid = false;
}
// Validate Email
const email = document.getElementById('email');
if (email.value.trim() === '') {
showError(email, 'Email is required.');
isValid = false;
} else if (!validateEmail(email.value.trim())) {
showError(email, 'Please enter a valid email.');
isValid = false;
}
// Validate Subject
const subject = document.getElementById('subject');
if (subject.value.trim() === '') {
showError(subject, 'Subject is required.');
isValid = false;
}
// Validate Message
const message = document.getElementById('message');
if (message.value.trim() === '') {
showError(message, 'Message is required.');
isValid = false;
}
if (isValid) {
// For now, just reset the form and show a success message
alert('Your message has been sent successfully!');
this.reset();
}
});
function showError(input, message) {
const error = input.parentElement.querySelector('.error-message');
error.textContent = message;
error.style.display = 'block';
}
function validateEmail(email) {
// Simple email regex
const re = /\S+@\S+\.\S+/;
return re.test(email);
}
Explanation:
Smooth Scrolling:
Selects all anchor tags that link to an ID on the page.
Adds a click event listener that prevents the default jump.
Scrolls smoothly to the target section, adjusting for the navbar height.
Form Validation:
On form submission, prevents the default behavior.
Checks each required field for input and proper format (email).
Displays error messages next to the respective fields if validation fails.
Shows an alert and resets the form if all validations pass.
Enhancements:
You can enhance the form by integrating with a backend service or using a service like Formspree to handle form submissions without backend development.
Final Touches and Deployment
SEO Optimization:
Add meta tags for description, keywords, and viewport.
Use semantic HTML tags (<header>, <nav>, <main>, <section>, <footer>, etc.) for better SEO.
Accessibility:
Ensure images have alt attributes.
Use proper heading hierarchy.
Ensure sufficient color contrast.
Performance Optimization:
Compress images to reduce load times.
Minify CSS and JavaScript files.
Utilize browser caching.
Deployment:
Choose a hosting platform (e.g., GitHub Pages, Netlify, Vercel).
Upload your project following the platform's guidelines.
Test the website across different devices and browsers to ensure responsiveness and functionality.
Conclusion
This guide provides a structured approach to building a fully responsive, multi-page website using HTML, CSS, and JavaScript. By following the outlined sections and adapting the code snippets to your specific needs, you can create a clean and modern website that includes all the required features. Remember to continuously test and refine your website to enhance user experience and performance.
If you encounter any issues or need further assistance with specific functionalities, feel free to ask!