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

  • SEARCH
  • Home
  • 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 123965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:22:14+00:00 2026-05-11T04:22:14+00:00

How could I vertically center a <div> within a <div> ? My code so

  • 0

How could I vertically center a <div> within a <div>?

My code so far:

<div style="height:322px;overflow:auto;">     <div style="border: Solid 1px #999999;padding:5px;">     </div> </div> 

i have tried "top:50%;" and "vertical-align:middle;" without success

For argument sake, how would I do it with a table then? I’ve used css for everything else so far so it’s not like I’m not trying to employ "good practices".

The inner div does not have a fixed height

  • 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. 2026-05-11T04:22:15+00:00Added an answer on May 11, 2026 at 4:22 am

    In short, you’re stuffed. More on this in a recent question I asked Can you do this HTML layout without using tables? Basically the CSS fanatics need to get a grip and realize there’s simply some things you can’t do (or can’t do well) without tables.

    This anti-table hysteria is nothing short of ridiculous.

    Table cells handle vertical centering really well and are backwards compatible as far as you could possibly care about. They also handle side-by-side content way better than floats, relative/absolute positioning or any of the other CSS type methods.

    Joel coined (or at least popularized) the term ‘architect astronauts’ in Don’t Let Architecture Astronauts Scare You. Well, in that same vein I think the term ‘CSS Astronaut’ (or ‘CSS Space Cadet’) is equally appropriate.

    CSS is an incredibly useful tool but it also has some pretty serious limitations. My favourite ishow numbered lists may only appear as ‘3.’ but not ‘3)’ or ‘(3)’ (at least prior to CSS3 generated content–or is it CSS2.1? Either way it’s not widely supported). What an oversight.

    But bigger than that is vertical centering and side-by-side layout. These two areas are still a huge problem for pure CSS. Another poster decided the relative positioning combined with negative margin heights was the way to go. How is that any better than:

    <html> <head>   <title>Layout</title>   <style type='text/css'>     #outer { height: 200px; border: 1px solid black; width: 600px; background-color: #DDD; }     #inner { width: 150px;  border: 1px solid red; background: yellow; margin: auto; line-height: 100%;  }   </style> </head> <body> <table> <tr> <td id='outer'>   <div id='inner'>Inner</div> </td> </tr> </table> </body> </html> 

    which will work everywhere, everytime.

    Here is an article on vertical centering in CSS. To achieve a similar thing they use three nested divs with relative+absolute+relative positioning just to get vertical centering. I’m sorry but whoever wrote that–and anyone who thinks that’s a good diea–has simply lost the plot.

    A counterargument is given in Tables vs CSS: CSS Trolls begone. The proof really is in the pudding. The vast majority of the top 20 (Alexa) sites still use tables for layout. With good reason.

    So decide for yourself: do you want your site to work and spend less time getting it to work? Or do you want to be a CSS Astronaut?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a couple of variants of a rename command,… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer There is currently no way to build CLS-compliant assemblies from… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer You might want to look at Google Protocol Buffers or… May 12, 2026 at 12:33 pm

Related Questions

after a hard work, my brain turns out of service.. (it is 11:40 P.M.
Say I have a grid with 3 rows. In the center row I'd like
How to center text over an image in a table cell using javascript, css,
If I have a button like the one in this image : http://www.freeimagehosting.net/image.php?4cd775814c.png how

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.