I have 4 HTML elements in a parent div ( "header" ) and I am trying to display the child div's side by side. The problem is that the background color of the div "headerTitle" spills out. How do i restrict the background color to just the font itself? And also if you look at the snapshot, the HTML elements towards the left are getting displaced to below the line ( they are not in line with the other elements. please help...
HTML code:
<div id="header" >
<div id="City1">
Cities
</div>
<div id="headerTitle">
Happy Stores
</div>
<div id="City2">
Cities
</div>
<div id="City3">
Cities
</div>
</div>
CSS code:
#City1
{
float:left;
}
#headerTitle
{
float:center;
background-color:gray;
}
#City2
{
float:right;
padding-left: 5px;
color:orange;
}
#City3
{
float:right;
background-color:pink;
}