🌐 Créer un site HTML - Guide complet
Je serais ravi de t'aider ! Voici un guide complet pour créer ton premier site HTML.
📁 Structure du projet
code Copy code
mon-site/
├── index.html
├── style.css
└── script.js
1️⃣ Fichier index.html - Structure de base
html Copy code
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mon Super Site</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- En-tête -->
<header>
<nav>
<h1>MonSite</h1>
<ul>
<li><a href="#accueil">Accueil</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<!-- Section principale -->
<main>
<section id="accueil" class="hero">
<h2>Bienvenue sur mon site !</h2>
<p>Voici mon premier site web créé avec HTML et CSS.</p>
<button onclick="saluer()">Cliquez-moi</button>
</section>
<section id="services">
<h2>Mes Services</h2>
<div class="services-grid">
<div class="carte">
<h3>Web Design</h3>
<p>Création de sites modernes et responsifs.</p>
</div>
<div class="carte">
<h3>Développement</h3>
<p>Applications web performantes.</p>
</div>
<div class="carte">
<h3>SEO</h3>
<p>Optimisation pour les moteurs de recherche.</p>
</div>
</div>
</section>
<section id="contact">
<h2>Contactez-moi</h2>
<form onsubmit="envoyerFormulaire(event)">
<input type="text" placeholder="Votre nom" required>
<input type="email" placeholder="Votre email" required>
<textarea placeholder="Votre message" required></textarea>
<button type="submit">Envoyer</button>
</form>
</section>
</main>
<!-- Pied de page -->
<footer>
<p>© 2024 MonSite - Tous droits réservés</p>
</footer>
<script src="script.js"></script>
</body>
</html>
2️⃣ Fichier style.css - Le style
css Copy code
/* Reset et base */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', sans-serif;
line-height: 1.6;
color: #333;
}
/* Navigation */
header {
background: #2c3e50;
color: white;
padding: 1rem;
position: sticky;
top: 0;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
max-width: 1200px;
margin: 0 auto;
}
nav ul {
display: flex;
list-style: none;
gap: 2rem;
}
nav a {
color: white;
text-decoration: none;
transition: color 0.3s;
}
nav a:hover {
color: #3498db;
}
/* Hero */
.hero {
text-align: center;
padding: 5rem 2rem;
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
}
.hero h2 {
font-size: 3rem;
margin-bottom: 1rem;
}
/* Services */
#services {
padding: 4rem 2rem;
max-width: 1200px;
margin: 0 auto;
}
.services-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
margin-top: 2rem;
}
.carte {
background: #f8f9fa;
padding: 2rem;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s;
}
.carte:hover {
transform: translateY(-5px);
}
/* Formulaire */
#contact {
padding: 4rem 2rem;
background: #f8f9fa;
}
form {
max-width: 500px;
margin: 2rem auto;
display: flex;
flex-direction: column;
gap: 1rem;
}
input, textarea {
padding: 0.8rem;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 1rem;
}
button {
padding: 0.8rem;
background: #3498db;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: #2980b9;
}
/* Footer */
footer {
text-align: center;
padding: 2rem;
background: #2c3e50;
color: white;
}
3️⃣ Fichier script.js - Interactivité
javascript Copy code
function saluer() {
alert('🎉 Bonjour ! Bienvenue sur mon site !');
}
function envoyerFormulaire(event) {
event.preventDefault();
alert('✅ Message envoyé avec succès !');
event.target.reset();
}
🚀 Comment lancer ton site ?
Crée les fichiers ci-dessus dans un dossier
Ouvre index.html dans ton navigateur (double-clic)
C'est tout ! 🎉
💡 Pour aller plus loin
Ressource Utilité VS Code Éditeur de code gratuit GitHub Pages Hébergement gratuit Netlify Déploiement en 1 clic MDN Web Docs Documentation officielle
❓ Dis-moi ce que tu veux !
Pour mieux t'aider, précise-moi :
🎯 Quel type de site ? (portfolio, blog, e-commerce, CV...)
🎨 Quel style ? (moderne, minimaliste, coloré...)
⚙️ Quelles fonctionnalités ? (formulaire, animations, base de données...)
Je peux t'adapter le code selon tes besoins ! 😊