How to add logo in website using HTML and CSS ?

Custom Logo Maker

To add a logo to your website using HTML and CSS, you can follow these steps:

1. Prepare your logo

Make sure you have your logo image file (common formats are .png, .jpg, or .svg) and place it in your project directory.


In your HTML file, create an <img> tag to display the logo. Set the src attribute to the file path of your logo image. You can also add an alt attribute to provide alternative text for accessibility.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Website</title>
    <link rel="stylesheet" href="styles.css">
        <div class="logo">
            <img src="path/to/your/logo.png" alt="Logo Description">
        <!-- Other header content goes here -->
    <!-- Rest of your website content -->

3. CSS

Use CSS to style the logo as needed. You can target the <img> tag directly or use a class or ID to style the logo element.

/* styles.css */
.logo {
    /* Add styles for your logo container */
    width: 150px; /* Set width as per your design */
    height: 150px; /* Set height as per your design */

.logo img {
    /* Add styles for your logo image */
    width: 100%; /* Make sure the image takes the full width of its container */
    height: 100%; /* Make sure the image takes the full height of its container */

In this example, the .logo class is applied to a <div> element wrapping the logo <img> tag. You can adjust the width, height, and other styles according to your design requirements.

Remember to replace “path/to/your/logo.png” with the actual file path to your logo image. Also, adjust the width, height, and other styles in the CSS code to fit your design preferences.

ALSO READ  Design Windows UI using HTML and CSS

Comments are closed.