1. Home
  2. Explore
  3. Computer Science
  4. Website with HTML & CSS

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Website with HTML & CSS

🌐 Creating a Website Using HTML and CSS Only


Introduction

This tutorial covers how to build a complete, visually appealing website using only HTML (HyperText Markup Language) and CSS (Cascading Style Sheets). The resulting site can be used for business, personal projects, or college assignments. The approach uses simple HTML tags and CSS styling, making it accessible to beginners.

  • Core Technologies: HTML for structure, CSS for presentation.

  • No JavaScript: All interactivity is limited to CSS hover effects and a link to Font Awesome icons.

  • Project Setup: A folder named website containing an index.html, a style.css, and a background image (1.jpg).


Project Structure & Setup

  1. Create a folder called website.

  2. Inside it, place a background image (e.g., 1.jpg).

  3. Open the folder in VS Code (or any code editor).

  4. Create two files:

    • index.html

    • style.css


HTML Structure (index.html)

The page is built using <div> elements with classes for layout organization. Below is the logical breakdown of the HTML sections.

Document Setup

<!DOCTYPE html>
<html>
<head>
    <title>Webpage Design</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
  • The <title> tag sets the browser tab name.

  • The CSS file is linked via <link>.

Main Container

<div class="main">
    <!-- all content goes here -->
</div>
  • .main is the outer wrapper that holds the entire page content.

Navbar

<div class="navbar">
    <div class="icon">
        <h2 class="logo">PraRoz</h2>
    </div>
    <div class="menu">
        <ul>
            <li><a href="#">HOME</a></li>
            <li><a href="#">ABOUT</a></li>
            <li><a href="#">SERVICE</a></li>
            <li><a href="#">DESIGN</a></li>
            <li><a href="#">CONTACT</a></li>
        </ul>
    </div>
    <div class="search">
        <input class="srch" type="text" placeholder="Type To text">
        <a href="#"> <button class="btn">Search</button></a>
    </div>
</div>
  • .icon contains the logo (<h2 class="logo">PraRoz</h2>).

  • .menu holds an unordered list of navigation links.

  • .search provides a text input and a search button.

Content / Hero Section

<div class="content">
    <h1>Web Design & <br><span>Development</span> <br>Course</h1>
    <p class="par">Lorem ipsum dolor sit amet consectetur adipiscing elit. ...</p>
    <button class="cn"><a href="#">JOIN US</a></button>
</div>
  • The <h1> uses a <span> to highlight "Development" in a different color.

  • The paragraph <p> is a placeholder description.

  • The JOIN US button links to a dummy # URL.

Login Form (Right Side)

<div class="form">
    <h2>Login Here</h2>
    <input type="email" name="email" placeholder="Enter Email Here">
    <input type="password" name="password" placeholder="Enter Password Here">
    <button class="btnn"><a href="#">Login</a></button>
    <p class="link">Don't have an account<br>
    <a href="#">Sign up </a> here</p>
    <p class="liw">Log in with</p>
</div>
  • A simple login box with email/password fields.

  • Includes a "Sign up" link and a line for social login icons.

Social Icons (Inside the Form)

Icons are added using Font Awesome. The script is linked in the <head>:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

Then inside .form or after the login box:

<div class="icons">
    <a href="#"><ion-icon name="logo-facebook"></ion-icon></a>
    <a href="#"><ion-icon name="logo-instagram"></ion-icon></a>
    <a href="#"><ion-icon name="logo-twitter"></ion-icon></a>
    <a href="#"><ion-icon name="logo-google"></ion-icon></a>
    <a href="#"><ion-icon name="logo-skype"></ion-icon></a>
</div>

Note: The tutorial uses both <ion-icon> and <i> tags. For simplicity, standard <i> or Font Awesome <i class="fab fa-facebook"></i> can be used.


CSS Styling (style.css)

All visual design is done in pure CSS. Key techniques used: gradient backgrounds, float-based layout, flexbox (for menu alignment), absolute positioning, and hover effects.

Global Reset & Background

* {
    margin: 0;
    padding: 0;
}

.main {
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0.5) 50%), url(1.jpg);
    background-position: center;
    background-size: cover;
    height: 100vh;
}
  • * selector removes default margin/padding.

  • .main uses a linear gradient overlay to darken the background image by 50%.

  • height: 100vh makes the container fill the full viewport.

Navbar Styling

.navbar {
    width: 1200px;
    height: 75px;
    margin: auto;
}

.icon {
    width: 200px;
    float: left;
    height: 70px;
}

.logo {
    color: orange;
    font-size: 35px;
    font-family: Arial;
    padding-left: 20px;
    float: left;
    padding-top: 10px;
}
  • .navbar is centered using margin: auto and has a fixed width of 1200px.

  • .icon is floated left to position the logo.

  • .logo text appears in orange with a specific font size and family.

Menu Styling

.menu {
    width: 400px;
    float: left;
    height: 70px;
}

ul {
    display: flex;
    justify-content: center;
    align-items: center;
}

ul li {
    list-style: none;
    margin-left: 62px;
    margin-top: 27px;
    font-size: 14px;
}

ul li a {
    text-decoration: none;
    color: white;
    font-family: Arial;
    font-weight: bold;
    transition: 0.4s ease-in-out;
}

ul li a:hover {
    color: orange;
}
  • The menu uses flexbox for horizontal alignment and centering.

  • Links are white, bold, and transition to orange on hover.

Search Bar Styling

.search {
    width: 330px;
    float: left;
    margin-left: 270px;
}

.srch {
    font-family: 'Times New Roman';
    width: 200px;
    height: 40px;
    background: transparent;
    border: 1px solid orange;
    margin-top: 13px;
    color: white;
    border-right: none;
    font-size: 16px;
    float: left;
    padding: 10px;
    border-bottom-left-radius: 5px;
    border-top-left-radius: 5px;
}

.btn {
    width: 100px;
    height: 40px;
    background: orange;
    border: 2px solid orange;
    margin-top: 13px;
    color: white;
    font-size: 15px;
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

.btn:focus,
.srch:focus {
    outline: none;
}
  • Input and button are styled as a unified search box with rounded corners on the left and right.

  • Focus outlines are removed for a cleaner look.

Hero Content Styling

.content {
    width: 100%;
    height: auto;
    margin: auto;
    color: white;
    position: relative;
}

.content .par {
    padding-left: 20px;
    padding-bottom: 25px;
    font-family: Arial;
    letter-spacing: 1.2px;
    line-height: 30px;
}

.content h1 {
    font-family: 'Times New Roman';
    font-size: 50px;
    padding-left: 20px;
    margin-top: 9%;
    letter-spacing: 2px;
}

.content .cn {
    width: 160px;
    height: 40px;
    background: orange;
    border: none;
    margin-bottom: 10px;
    margin-left: 20px;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
}

.content .cn a {
    text-decoration: none;
    color: black;
    transition: 0.3s ease;
}

.cn:hover {
    background: white;
}

.content span {
    color: orange;
    font-size: 60px;
}
  • The <span> inside <h1> is styled orange and larger (60px) to emphasize "Development".

  • The "JOIN US" button has rounded corners and changes background on hover.

Login Form Styling

.form {
    width: 250px;
    height: 380px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 50%, rgba(0,0,0,0.8) 50%);
    position: absolute;
    top: -20px;
    left: 870px;
    border-radius: 10px;
    padding: 25px;
}

.form h2 {
    width: 220px;
    font-family: sans-serif;
    text-align: center;
    color: orange;
    font-size: 22px;
    background-color: white;
    border-radius: 10px;
    margin: 2px;
    padding: 8px;
}

.form input {
    width: 240px;
    height: 35px;
    background: transparent;
    border-bottom: 1px solid orange;
    border-top: none;
    border-right: none;
    border-left: none;
    color: white;
    font-size: 15px;
    letter-spacing: 1px;
    margin-top: 30px;
    font-family: sans-serif;
}

.form input:focus {
    outline: none;
}

::placeholder {
    color: white;
    font-family: Arial;
}

.btnn {
    width: 240px;
    height: 40px;
    background: orange;
    border: none;
    margin-top: 30px;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    color: white;
}

.btnn:hover {
    background: white;
    color: orange;
}

.btnn a {
    text-decoration: none;
    color: black;
    font-weight: bold;
}

.form .link {
    font-family: Arial;
    font-size: 17px;
    padding-top: 20px;
    text-align: center;
}

.form .link a {
    text-decoration: none;
    color: orange;
}

.liw {
    padding-top: 15px;
    padding-bottom: 10px;
    text-align: center;
}
  • The form is absolutely positioned at the right side (left: 870px).

  • The background uses a gradient overlay to make it semi-transparent.

  • Inputs have only a bottom border (orange) for a modern underline style.

  • The login button and hover effects mirror the rest of the site.

Social Icons Styling

.icons a {
    text-decoration: none;
    color: white;
}

.icons a ion-icon {
    color: white;
    font-size: 30px;
    padding-left: 14px;
    padding-top: 5px;
    transition: 0.3s ease;
}

.icons a ion-icon:hover {
    color: orange;
}
  • Icons appear white by default and turn orange on hover.

  • The transition creates a smooth color change.


Key CSS Techniques Used

  • Gradient Overlay: linear-gradient(to top, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0.5) 50%), url(1.jpg) darkens the background image.

  • Float Layout: .icon, .menu, .search are floated left to create a horizontal navbar.

  • Flexbox: Used in the <ul> for centering menu items.

  • Absolute Positioning: .form is positioned absolutely within the .main container (which has position: relative implicitly, but .content has position: relative). The form sits on the right.

  • CSS Transitions: transition: 0.4s ease-in-out on menu links and buttons for smooth hover effects.

  • Border Radius: Rounded corners on buttons and the login box.


Final Output

The completed webpage features:

  • A full-screen background image with a dark overlay.

  • A fixed-width navbar at the top with logo, menu links, and a search bar.

  • A hero section with a large heading (with highlighted "Development"), a paragraph, and a call-to-action button.

  • A login form positioned on the right side with email/password fields and social media icons.

  • Consistent color scheme: orange for accents, white for text, and black/dark backgrounds.

  • Hover effects on links and buttons (color changes).


Summary of Concepts Learned

  1. HTML Structure: Using <div> with classes to create sections (navbar, content, form).

  2. CSS Selectors: Class selectors (.class), element selectors (ul, input), pseudo-classes (:hover, :focus).

  3. Layout Methods: Float for horizontal positioning, flexbox for alignment, absolute positioning for overlays.

  4. CSS Backgrounds: background-image, background-size: cover, background-position, and gradients.

  5. Typography: Font families, letter-spacing, line-height, font-weight.

  6. Box Model: Margins, padding, borders, width/height.

  7. Buttons & Links: Styling buttons consistently, removing underlines, changing cursor.

  8. External Libraries: Linking and styling Font Awesome icons.

This project demonstrates that a professional-looking website can be built with just HTML and CSS, without any JavaScript frameworks. The techniques shown are fundamental for any web developer.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent