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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:01:36+00:00 2026-05-15T00:01:36+00:00

BACKGROUND: I would like to have small labels in columns of a table. I’m

  • 0

BACKGROUND:

I would like to have small labels in columns of a table.
I’m using some implemented parts of HTML5/CSS3 in my project, and this section specifically is for mobile devices. While both facts are not necessarily relevant, the bottom line is that I don’t have to support Internet Explorer or even Firefox for that matter (just WebKit).

THE PROBLEM

With my current CSS approach, the vertical padding of the cell comes from the <span> element (set to display: block with top/bottom margins), which contains the “value” of the column. As a result there’s no padding when the <span> is empty or missing (no value) and the label is not in place.

The “full” coulmns should give you the idea of where I want the labels to be, even if there’s no value, and the <span> is not there.

I realize that I could use “non-breaking-space”, but I would really like to avoid it.

I wonder if any of you have a fix / better way to do this? current code is below.

<!DOCTYPE html>
<html lang="en">
<head>
<title>ah</title>
<style>

body {
 width: 320px;
}

/* TABLE */

table { width: 100%; border-collapse: collapse; font-family: arial; }
th, td { border: 1px solid #ccc; border-width: 0px 0px 1px 1px; }
th:last-child, td:last-child { border-right-width: 1px; }
tr:first-child th { border-top-width: 1px; background: #efefef; }

/* RELEVANT STUFF */

td {
 padding: 3px;
}

td sup {
 display: block;
}

td span {
 display: block;
 margin: 3px 0px;
 text-align: center;
}

</style>
</head>
<body>

<table>
    <tr>
        <th colspan="3">something</th>
    </tr>
    <tr>
        <td><sup>some label</sup><span>any content</span></td>
        <td><sup>some label</sup><span>any content</span></td>
        <td><sup>some label</sup><span></span></td><!-- No content, just a label -->
    </tr>
</table>

</body>
</html>
  • 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-15T00:01:37+00:00Added an answer on May 15, 2026 at 12:01 am

    As above, you can use:

    td {
     padding: 3px;
     vertical-align:top;
    }
    

    If you wanted to retain the padding exactly, even on the invisible elements, you can force the hasLayout attribute on the empty span using:

    td {
     padding: 3px;
      vertical-align:top;
    }
    
    td sup {
     display: block;
    }
    
    td span {
     display: inline-block;
     margin: 3px 0px;
     text-align: center;
     width:100%;
    }
    

    The inline-block technique is discussed extensively at Drawing empty inline boxes in CSS?

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

Sidebar

Related Questions

Background: I would like to dismiss a modalView that I have presented earlier and
I have a java program that is running in the background(Windows). I would like
Background I would like my Python script to pause before exiting using something similar
I would like to add some background music to the splash screen in the
I would like to prevent unnecessary use of background-size in CSS3. By the way,
I have a small menu div that i would like to keep in the
I have a full screen fixed background image. I would like the text in
I'm using jquery mobile, and I have a image that I would like to
Some background information The files I would like to download is kept at the
I have a parent DIV that contains three other small DIV's. I would like

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.