Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logo image and H1 heading on the same line

I want to create my first web page but I encountered a problem.

I have the following code:

<img src="img/logo.png" alt="logo" /> <h1>My website name</h1> 

I'd like to know how to make the logo and the H1 to be in the same line. Thanks!

like image 350
Six Quads Avatar asked Jul 28 '12 13:07

Six Quads


People also ask

How do you make an image and a header be in the same line in HTML?

Just stick the img tag inside the h1 tag as part of the content.

Can you put an image inside an H1?

You can place an image inside an h1 element, but not quite like that … the alt attribute is mandatory. Show activity on this post. To summarize the other answers, it is W3C valid to use an <img> inside an <h1> . Though to be completly valid you should add an alt attribute to your image, because it's mandatory.


1 Answers

As example (DEMO):

HTML:

<div class="header">   <img src="img/logo.png" alt="logo" />   <h1>My website name</h1> </div> 

CSS:

.header img {   float: left;   width: 100px;   height: 100px;   background: #555; }  .header h1 {   position: relative;   top: 18px;   left: 10px; } 

DEMO

like image 99
Danil Speransky Avatar answered Nov 09 '22 18:11

Danil Speransky