Write the best website that you can only using html css and js, divide only all languages
- User
Write the best website that you can only using html css and js, divide only all languages
- Assistant
Write the best website that you can only using html css and js, divide only all languages
Creating a high-quality, modern website using only HTML, CSS, and JavaScript involves structuring your code effectively, ensuring responsiveness, and adding interactivity to enhance user experience. Below is an example of a simple yet elegant personal portfolio website divided into separate files for each language: index.html, styles.css, and script.js.
index.htmlThis is the main HTML file that structures the content of your website.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Portfolio</title>
<!-- Link to external CSS -->
<link rel="stylesheet" href="styles.css">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<!-- Navigation Bar -->
<nav class="navbar">
<div class="container">
<div class="logo">MyPortfolio</div>
<ul class="nav-links">
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#projects">Projects</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<div class="hamburger">
<span></span>
<span></span>
<span></span>
</div>
</div>
</nav>
<!-- Home Section -->
<section id="home" class="section home-section">
<div class="container">
<h1>Welcome to My Portfolio</h1>
<p>I'm a passionate web developer.</p>
<a href="#projects" class="btn">View My Work</a>
</div>
</section>
<!-- About Section -->
<section id="about" class="section about-section">
<div class="container">
<h2>About Me</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ac vestibulum erat.
Cras vulputate auctor lectus at consequat.
</p>
<div class="skills">
<div class="skill">HTML</div>
<div class="skill">CSS</div>
<div class="skill">JavaScript</div>
<div class="skill">React</div>
</div>
</div>
</section>
<!-- Projects Section -->
<section id="projects" class="section projects-section">
<div class="container">
<h2>My Projects</h2>
<div class="projects-grid">
<!-- Project Card -->
<div class="project-card">
<img src="project1.jpg" alt="Project 1">
<h3>Project One</h3>
<p>A brief description of Project One.</p>
<a href="#" class="btn">View Details</a>
</div>
<!-- Repeat Project Cards as needed -->
<div class="project-card">
<img src="project2.jpg" alt="Project 2">
<h3>Project Two</h3>
<p>A brief description of Project Two.</p>
<a href="#" class="btn">View Details</a>
</div>
<div class="project-card">
<img src="project3.jpg" alt="Project 3">
<h3>Project Three</h3>
<p>A brief description of Project Three.</p>
<a href="#" class="btn">View Details</a>
</div>
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact" class="section contact-section">
<div class="container">
<h2>Contact Me</h2>
<form id="contact-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="message">Message</label>
<textarea id="message" rows="5" required></textarea>
</div>
<button type="submit" class="btn">Send Message</button>
</form>
</div>
</section>
<!-- Footer -->
<footer class="footer">
<div class="container">
<p>© 2023 MyPortfolio. All rights reserved.</p>
<div class="social-links">
<a href="#" target="_blank">LinkedIn</a>
<a href="#" target="_blank">GitHub</a>
<a href="#" target="_blank">Twitter</a>
</div>
</div>
</footer>
<!-- Link to external JS -->
<script src="script.js"></script>
</body>
</html>
styles.cssThis CSS file styles the HTML elements to create a visually appealing design. It includes responsive design for various screen sizes.
/* Reset & Base Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
line-height: 1.6;
color: #333;
}
.container {
width: 90%;
max-width: 1200px;
margin: auto;
}
/* Navigation Bar */
.navbar {
background-color: #fff;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
position: fixed;
width: 100%;
top: 0;
z-index: 1000;
}
.navbar .container {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 0;
}
.logo {
font-size: 1.5rem;
font-weight: bold;
}
.nav-links {
list-style: none;
display: flex;
}
.nav-links li {
margin-left: 20px;
}
.nav-links a {
text-decoration: none;
color: #333;
transition: color 0.3s ease;
}
.nav-links a:hover {
color: #007BFF;
}
/* Hamburger Menu (Mobile) */
.hamburger {
display: none;
flex-direction: column;
cursor: pointer;
}
.hamburger span {
height: 3px;
width: 25px;
background: #333;
margin-bottom: 4px;
border-radius: 5px;
}
/* Sections */
.section {
padding: 100px 0;
min-height: 100vh;
}
.home-section {
background: url('home-bg.jpg') no-repeat center center/cover;
color: #fff;
text-align: center;
display: flex;
align-items: center;
}
.home-section h1 {
font-size: 3rem;
margin-bottom: 20px;
}
.btn {
display: inline-block;
padding: 10px 20px;
background: #007BFF;
color: #fff;
text-decoration: none;
border-radius: 5px;
transition: background 0.3s ease;
}
.btn:hover {
background: #0056b3;
}
.about-section, .projects-section, .contact-section {
background: #f9f9f9;
}
.about-section h2, .projects-section h2, .contact-section h2 {
text-align: center;
margin-bottom: 40px;
}
.skills {
display: flex;
justify-content: center;
flex-wrap: wrap;
margin-top: 20px;
}
.skill {
background: #007BFF;
color: #fff;
padding: 10px 15px;
margin: 5px;
border-radius: 20px;
font-size: 0.9rem;
}
/* Projects Grid */
.projects-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 20px;
}
.project-card {
background: #fff;
border: 1px solid #ddd;
border-radius: 10px;
overflow: hidden;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.project-card img {
width: 100%;
height: 180px;
object-fit: cover;
}
.project-card h3 {
margin: 15px;
}
.project-card p {
margin: 0 15px 15px 15px;
color: #666;
}
.project-card .btn {
margin: 0 15px 15px 15px;
}
.project-card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
/* Contact Form */
#contact-form {
max-width: 600px;
margin: auto;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
.footer {
background: #333;
color: #fff;
padding: 20px 0;
text-align: center;
}
.footer .social-links a {
color: #fff;
margin: 0 10px;
text-decoration: none;
transition: color 0.3s ease;
}
.footer .social-links a:hover {
color: #007BFF;
}
/* Responsive Design */
@media (max-width: 768px) {
.nav-links {
position: absolute;
top: 60px;
left: -100%;
flex-direction: column;
background: #fff;
width: 100%;
transition: left 0.3s ease;
}
.nav-links.active {
left: 0;
}
.nav-links li {
margin: 15px 0;
text-align: center;
}
.hamburger {
display: flex;
}
.home-section h1 {
font-size: 2.5rem;
}
.skills {
flex-direction: column;
align-items: center;
}
}
script.jsThis JavaScript file adds interactivity to the website, such as toggling the navigation menu on mobile devices and handling form submissions.
// Toggle Navigation Menu on Mobile
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', () => {
navLinks.classList.toggle('active');
hamburger.classList.toggle('active');
});
// Smooth Scrolling for Navigation Links
const navItems = document.querySelectorAll('.nav-links a');
navItems.forEach(item => {
item.addEventListener('click', (e) => {
e.preventDefault();
const targetId = item.getAttribute('href').substring(1);
const targetSection = document.getElementById(targetId);
window.scrollTo({
top: targetSection.offsetTop - 60,
behavior: 'smooth'
});
// Close the menu if open on mobile
if (navLinks.classList.contains('active')) {
navLinks.classList.remove('active');
hamburger.classList.remove('active');
}
});
});
// Handle Contact Form Submission
const contactForm = document.getElementById('contact-form');
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
// Simple form validation
const name = document.getElementById('name').value.trim();
const email = document.getElementById('email').value.trim();
const message = document.getElementById('message').value.trim();
if (name === '' || email === '' || message === '') {
alert('Please fill in all fields.');
return;
}
// Normally, you'd send the form data to a server here
// For this example, we'll just display a success message
alert('Thank you for your message! I will get back to you soon.');
// Reset the form
contactForm.reset();
});
Your project directory should be organized as follows:
my-portfolio/
├── index.html
├── styles.css
├── script.js
├── images/
│ ├── home-bg.jpg
│ ├── project1.jpg
│ ├── project2.jpg
│ └── project3.jpg
└── fonts/
└── (if any custom fonts are used)
Images and Assets: Ensure that all images (home-bg.jpg, project1.jpg, etc.) are optimized for web to reduce loading times. Place them in an images folder as shown in the file structure.
Responsive Design: The provided CSS includes media queries to make the website responsive. Test the website on different devices and screen sizes to ensure it looks good everywhere.
Accessibility: Use semantic HTML elements and ensure that your website is accessible to all users, including those using screen readers.
Performance Optimization: Minify your CSS and JavaScript files for better performance in a production environment. You can use tools like CSSNano and UglifyJS for this purpose.
SEO Best Practices: Use appropriate meta tags, descriptive titles, and alt attributes for images to improve your website's SEO.
Deployment: You can deploy your website using platforms like GitHub Pages, Netlify, or Vercel.
This example provides a foundational structure for a personal portfolio website using only HTML, CSS, and JavaScript. You can expand upon this by adding more sections, enhancing styles, integrating animations, or incorporating additional interactivity as needed. Remember to keep your code clean and well-organized to facilitate maintenance and scalability.