Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6596379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:04:06+00:00 2026-05-25T18:04:06+00:00

I am trying to align a element center in a div where i am

  • 0

I am trying to align a element center in a div where i am not giving any width to parent div becouse it will spread according to screen size , there is total 3 element in div :

  1. Buttons
  2. Heading
  3. Logo

buttons will always align left and logo will align right whenever screen size will be change and the heading will always align center like this
enter image description here

My code is here
http://jsfiddle.net/7AE7J/1/
please let me know where i am going wrong and what css i should apply for getting the element (heading) align center always.

HTML

<div  id="header">
     <div id="buttons">
        <a href="#" class="button_back">link 1</a>
        <a href="#" class="button_back">link 2</a>
    </div>
        <h1>Heading of the page</h1>
    <div id="logo">
        <a href="#">
           <img src="http://lorempixum.com/60/60" width="178" height="31" alt="logo" />
       </a>
    </div>
</div>

CSS

#header {
     background:green;
     height:44px;
    width:100% }

 #buttons {
     float: left;
     margin-top: 7px;
     }

 #buttons a {
     display: block;
     font-size: 13px;
     font-weight: bold;
     height: 30px;
     text-decoration: none;
     color:blue;
    float:left}

 #buttons a.button_back {
     margin-left: 8px;
     padding-left:10px;
     padding-top: 8px;
    padding-right:15px }

 #header h1 {
     color: #EEEEEE;
     font-size: 21px;
     padding-top: 9px ;
     margin:0 auto}

 #logo {
     float: right;
    padding-top: 9px;
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:04:07+00:00Added an answer on May 25, 2026 at 6:04 pm

    You can use inline-block for this:

    #header {
      text-align: center;
    }
    
    #header h1 {
      display: inline-block;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse this content using jsoup. <div class=imageInlineCenter style=width: 468px; align=center><img
I am trying to middle align an element, But I have bumped into this
I have the following element that I parsed out of a <table> <td align=center
I am trying to center my facebook like button. It is within a div
Why is trying to align something in the center of the viewport (or wrapper)
I have a div element with a background image that I am vertically trying
I'm trying to make hover effect which will change height of li (list) element
I have a <div> element with a fixed height, and I'd like to center
i am trying to get my site to auto center a div that has
i am trying to center my horizontal <ul> inside a <div> (the yellow stripe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.