Companies typically display logos in navigation bars using one of these methods:
<a href="#" class="logo">
<img src="logo.png" alt="Company Name" />
Company Name
</a>Pros:
- Simple and reliable
- Works in all browsers
- Easy to control size
- Can be cached by browser
.logo::before {
content: '';
display: inline-block;
width: 1.5rem;
height: 1.5rem;
background-image: url('logo.png');
background-size: contain;
}Pros:
- No HTML changes needed
- Can be styled with CSS
- Good for icons
Cons:
- Less semantic
- Harder to debug if image doesn't load
<a href="#" class="logo">
<svg width="24" height="24">...</svg>
Company Name
</a>Pros:
- Scalable (vector)
- Can be styled with CSS
- No separate image file
<a href="#" class="logo">
<i class="icon-logo"></i>
Company Name
</a>Pros:
- Very lightweight
- Easy to color/style
- Scales perfectly
We're using Method 1 (Image Tag) which is the most reliable approach.
- File:
website/logo.png - Path in HTML:
src="logo.png"(relative to index.html) - Size: 1.5rem × 1.5rem (~24px × 24px)
If logo doesn't show:
- Check file exists:
website/logo.png - Check path: Should be same folder as
index.html - Check browser console: Look for 404 errors
- Try absolute path:
/logo.pngor./logo.png - Check file permissions: File should be readable
- Use SVG for logos when possible (scalable, small file size)
- Optimize PNG/JPEG images (compress, use appropriate dimensions)
- Provide alt text for accessibility
- Use appropriate sizes:
- Navigation bar: 24-32px height
- Favicon: 16×16 or 32×32px
- Hero section: Larger (48-64px)
For best results, convert your logo to SVG:
- Better scalability
- Smaller file size
- Can be styled with CSS
- Works at any resolution