Logo image and H1 heading on the same line

Six Quads picture Six Quads · Jul 28, 2012 · Viewed 449.1k times · Source

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!

Answer

Danil Speransky picture Danil Speransky · Jul 28, 2012

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