HTML & CSS code examples
If want some sources codes you can copy those codes and use in your projects or anywhere you want to.

Responsive html & css navigation bar
Learn how to make a simple and easy responsive navbar step by step.


Step 1. Add HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Simple Navbar</title>
</head>
<body>
<nav class="navbar">
<div class="logo">Nav Bar</div>
<input type="checkbox" id="menu-toggle">
<label for="menu-toggle" class="menu-icon">☰</label>
<ul class="nav-links">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</body>
</html>
Step 2. Add CSS
Create an external (separate) file for css.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
.navbar {
background: blue;
color: #fff;
padding: 15px 20px;
display: flex;
align-items: center;
justify-content: space-between;
}
.logo {
font-size: 22px;
font-weight: bold;
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-left: 20px;
}
.nav-links a {
color: white;
text-decoration: none;
padding: 8px 12px;
border-radius: 4px;
}
.nav-links a:hover {
background: red;
}
/* Mobile Styles */
#menu-toggle {
display: none;
}
.menu-icon {
display: none;
font-size: 28px;
cursor: pointer;
}
/* Responsive */
@media (max-width: 768px) {
.menu-icon {
display: block;
}
.nav-links {
position: absolute;
top: 60px;
left: 0;
background: #222;
width: 100%;
flex-direction: column;
display: none;
}
.nav-links li {
margin: 15px 0;
text-align: center;
}
#menu-toggle:checked ~ .nav-links {
display: flex;
}
}
Simple contact form
How to create a simple contact form in html css.

Step 1. Add HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Form</title>
</head>
<body>
<div class="form-box">
<h2>Contact Form</h2>
<form>
<label>Name</label>
<input type="text" placeholder="Enter your name" required>
<label>Email</label>
<input type="email" placeholder="Enter your email" required>
<label>Message</label>
<input type="text" placeholder="Enter your message" required>
<button type="submit">Submit</button>
</form>
</div>
</body>
</html>
Step 2. Add CSS
Create an external css file.
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.form-box {
background: #fff;
padding: 25px;
width: 320px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.form-box h2 {
margin-bottom: 15px;
text-align: center;
}
.form-box label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-box input {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-box button {
width: 100%;
padding: 10px;
background: #007bff;
color: #fff;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
.form-box button:hover {
background: #0056b3;
}