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 8252203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:29:53+00:00 2026-06-08T00:29:53+00:00

I Have a Caption with Dynamic Width, and i Want it in the center

  • 0

I Have a Caption with Dynamic Width, and i Want it in the center of the table, but inline-block isnt working right, the inline make it in the center of the td, not of all the table, How can i make it in the center of the table? Here is a example of this html:

<table class="hours-table" style="width: 100%;" border="0"><caption>Title</caption>
<tbody>
<tr>
<td>1_1</td>
<td>1_2</td>
<td>1_3</td>
<td>1_4</td>
<td>1_5</td>
</tr>
<tr>
<td>2_1</td>
<td>2_2</td>
<td>2_3</td>
<td>2_4</td>
<td>2_5</td>
</tr>
<tr>
<td>3_1</td>
<td>3_2</td>
<td>3_3</td>
<td>3_4</td>
<td>3_5</td>
</tr>
<tr>
<td>4_1</td>
<td>4_2</td>
<td>4_3</td>
<td>4_4</td>
<td>4_5</td>
</tr>
<tr>
<td>5_1</td>
<td>5_2</td>
<td>5_3</td>
<td>5_4</td>
<td>5_5</td>
</tr>
</tbody>
</table>

Thanks a lot in Advance!

  • 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-06-08T00:29:56+00:00Added an answer on June 8, 2026 at 12:29 am

    If you want it to be both vertically and horizontally aligned in the center, you could use the following CSS:

    table { position: relative; }
    caption {
        ​position: absolute;
        top: 50%;
        left: 50%;
        margin: -0.5em -10px; /* Change the -10px part depending on length of title */
    }​
    

    jsFiddle

    If you only want it to be horizontally aligned (at the top of the table, you could use:

    caption { text-align: center; }
    

    ​
    jsFiddle

    Edit: Here is a solution that will allow a background behind a centered caption but also create a white background behind just the text part of the caption:

    HTML

    <caption>Title</caption>
    

    CSS

    div { background: url('background_image.jpg') repeat; }
    caption {
        text-align: center;
        background: rgba(0,0,0,0);
    }
    span { background: white; }
    

    JS

    $(function() {
        var caption = $('caption');
        caption.html('<span>' + caption.html() + '</span>');
        });​
    

    jsFiddle

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

Sidebar

Related Questions

I have a problem. I want to copy a caption of a label from
I have a LaTeX table that looks like this: \begin{table}[!ht] \centering \small \caption{ \bf{Caption}}
I'm working with TListView and I have successfully populated each item's caption and first
i have created dynamic button with code below, the button caption is too long
I have a custom table-environment defined with \newenvironment. I have a caption in this
I have the following code being echoed: [caption id=attachment_13 align=alignnone width=235 caption=Event 1] <img
Here's what I want to do. I have a caption that changes every time
I have a table which has a caption which appears on top of the
I have a caption for a GUI control, and I want to convert it
I have the caption parameter set in the jqGrid definition. I want to know

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.