Skip to content Skip to sidebar Skip to footer

Align Image And List On Same Line In Html

Currently I am trying to create a header section in HTML, which contains a logo image and a list which is being used as a navigation menu. The problem which I am facing right now i

Solution 1:

Add a vertical-align attribute to your images

.header-section > img
{
    display:inline-block;
    padding:10px;
    background-color:yellow;
    vertical-align: middle;
}

Update : Float version
Add a "float left" attribute to your images and .navigation and set an image "height + padding" equal to the line-height of your list.

.header-section
{
  overflow: hidden;
}
.header-section > img
{
    float: left;
    padding:10px;
    background-color:yellow;
    width: 30px;
    height: 30px;
}
.navigation
{
    padding: 0;
    margin: 0;
    float: left;
    list-style:none;
}
.navigation
{
    background-color:red;
}
.navigation > li
{
    display:inline;
    text-align:center;
    line-height:50px;
}
.navigation ul
{
    display:none;
}
<!--Header section-->
<div class="header-section">
	<img src="images/logo/logo.png">
	<!--Navigation section-->
	<ul class="navigation">
		<li><a href="#">Home</a></li>
		<li class="sub-menu">
			<a href="#">About &#x25BC;</a>
			<ul>
				<li><a href="#">The Company</a></li>
				<li><a href="#">The Founders</a></li>
				<li><a href="#">The Team</a></li>
				<li><a href="#">The Mission</a></li>
			</ul>
		</li>
		<li class="sub-menu">
			<a href="#">Products  &#x25BC;</a>
			<ul>
				<li><a href="#">Solar Panels</a></li>
				<li><a href="#">Solar Lamps</a></li>
				<li><a href="#">Solar Heaters</a></li>
				<li><a href="#">Solar Cookers</a></li>
			</ul>
		</li>
		<li class="sub-menu">
			<a href="#">Services &#x25BC;</a>
			<ul>
				<li><a href="#">Solar Equipment Repair</a></li>
				<li><a href="#">Installation</a></li>
				<li><a href="#">Maintenance</a></li>
				<li><a href="#">Training</a></li>
			</ul>
		</li>
		<li class="sub-menu">
			<a href="#">Support &#x25BC;</a>
			<ul>
				<li><a href="#">Training</a></li>
			</ul>
		</li>
		<li class="sub-menu">
			<a href="#">Contact &#x25BC;</a>
			<ul>
				<li><a href="#">Email Us</a></li>
				<li><a href="#">Contact Form</a></li>
			</ul>
		</li>
	</ul>
	<!--Social Icons-->
	<img src="images/icons/twitter.png">
	<img src="images/icons/facebook.png">
	<img src="images/icons/google-plus.png">
</div>
<!--Header section closed-->

Post a Comment for "Align Image And List On Same Line In Html"