How to add logo in website using HTML and CSS ?

0
444
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.

2. HTML

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">
<head>
    <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">
</head>
<body>
    <header>
        <div class="logo">
            <img src="path/to/your/logo.png" alt="Logo Description">
        </div>
        <!-- Other header content goes here -->
    </header>
    <!-- Rest of your website content -->
</body>
</html>

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.