Quadruple Equidistant Table Containers

I am struggling to achieve the desired outcome of having four evenly spaced <table> cells on my webpage. Despite setting specific widths for each cell, I am facing some challenges.

Below is an example where one of the cells appears larger than the rest:

<tr>
    <td style="width: 100%; padding: 0px 20px 0px 20px;" cellspacing="0" cellpadding="20" border="0" colspan="12" align="center">
        <table style="width: 600px; border-collapse: collapse; border: 1px solid orange;" cellspacing="0" cellpadding="20" border="0" colspan="12" align="center">
            <tbody cellspacing="0" cellpadding="0" border="0" colspan="12" align="center" style="width: 100%;" width="100%">
                <tr cellspacing="0" cellpadding="0" border="0" colspan="12" align="center" style="width: 100%;" width="100%">
                    <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1F1F1F; text-align: center; border: 1px solid orange; font-family: Helvetica, Arial, Verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" >
                        <img src="http://dummyimage.com/50x50/000/fff.jpg&text=Icon" alt="Bullhorn Icon" width="50" height="50" /><br />
                        <p style="font-family: Helvetica, Arial, Verdana; font-size: 10px; color: #1F1F1F; text-align: center;">Dolorla ti <br />amet silio</p>
                    </td>
                    <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1F1F1F; text-align: center; border: 1px solid orange; font-family: Helvetica, Arial, Verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" >
                        <img src="http://dummyimage.com/50x50/000/fff.jpg&text=Icon" alt="Lab Icon" width="50" height="50" /><br />
                        <p style="font-family: Helvetica, Arial, Verdana; font-size: 10px; color: #1F1F1F; text-align: center;">Adipiscing <br />consecteture</p>
                    </td>
                    <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1F1F1F; text-align: center; border: 1px solid orange; font-family: Helvetica, Arial, Verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" >
                        <img src="http://dummyimage.com/50x50/000/fff.jpg&text=Icon" alt="Atom Icon" width="50" height="50" /><br />
                        <p style="font-family: Helvetica, Arial, Verdana; font-size: 10px; color: #1F1F1F; text-align: center;">Facili elit <br />torem</p>
                    </td>
                    <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1F1F1F; text-align: center; border: 1px solid orange; font-family: Helvetica, Arial, Verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" >
                        <img src="http://dummyimage.com/50x50/000/fff.jpg&text=Icon" alt="File Icon" width="50" height="50" /><br />
                        <p style="font-family: Helvetica, Arial, Verdana; font-size: 10px; color: #1F1F1F; text-align: center;">Ipsum sit <br />sepida colt</p>
                    </td>
                </tr>
            </tbody>
        </table>
    </td>
</tr>

JSFiddle

Can someone guide me on how to create four evenly-spaced table cells?

Answer №1

To achieve the desired outcome, it is imperative to utilize the table-layout property.

http://www.w3.org/TR/CSS21/tables.html#fixed-table-layout

In this particular scenario:

<table style="width: 600px; border-collapse: collapse; border: 1px solid orange;table-layout:fixed;" cellspacing="0" cellpadding="20" border="0" colspan="12" align="center">

DEMO

Answer №2

Upon inspection of the parsed content using developer tools such as Chrome, you may observe that the <td> elements have their width property overridden from width: 148px to a computed width like 103.8546546px, and so forth. To achieve your desired result, simply include the following CSS:

table {
    table-layout: fixed;
}

This can be added either to your external CSS file or applied as an inline style. By doing so, you should see the expected outcomes.

Forked Fiddle: http://jsfiddle.net/CaVpC/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Arrange symbols in fontawesome into a pile

Is there a way to stack grid icons in the font awesome framework to create a 3x2 grid icon? Demonstration Jsfiddle <a href="./"><i class="fa fa-square"></i> 1x1</a> <a href="./" ><i class="fa fa-square"></i>< ...

Improving Java Performance by frequently replacing one String with another

Currently, I am developing an HttpServlet extension (plugin) for a CMS that is responsible for filtering the HTML response. Within my method filterResponse, I retrieve the requested text/html as a String, which is one of three parameters. The main task a ...

Guide to repairing a CSS ball animation

I am attempting to create a simulation where a ball moves in the following pattern: bottom right -> top center -> bottom (/) left. However, my animation seems to be moving from top right -> bottom center -> top left (/). #stage { height:300 ...

hitting the value of the text input

Is there a way to strike through only the first word in an input box of type text, without editing the html? I've tried using css text-decoration: line-through; but it's striking both words. Any suggestions on how to achieve this using javascript ...

Tips for adjusting your Navbar from transparent to solid based on screen size changes instead of scrolling

I am seeking assistance in creating a responsive Navbar that transitions from transparent to solid when the screen size changes, such as on a smartphone. I want the Navbar to remain fixed at the top of the page and not move down as I scroll. I tried adding ...

Including v-menu in a button causes it to vanish in Vuetify

I am facing an issue with my stepper. Specifically, in step 3, I am trying to add a v-menu to a button but when I do so, the button disappears. Below is the code snippet causing the problem: <template> . . . . <v-stepper-step :complete="e6 > ...

Having trouble getting the CSS 3 Spin feature to work?

Using webkit for previewing in chrome. The spinning circles I created are not working properly (definitely not an HTML issue.) #loader-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; } #loader { display: inline-bl ...

Formatting won't assist in aligning Facebook button

I am currently working on a page that includes a div with a Facebook recommend button. In order to style the Facebook code, I enclosed it with this formatting: <div style="align:center"> <div id="fb-root"></div> <script src=" ...

Creating a variable with the use of @include

Here's a question that I need help with. I have a SASS @include function that dynamically calculates the font size. h2 { @include rfs(2rem); } I use this to adjust the font size based on screen resolution, but I'm facing an issue where a gre ...

Maintaining text color while adding a color overlay to a Bootstrap Jumbotron

After searching extensively, I couldn't find any mention of this particular issue. According to the Bootstrap 4.2 documentation on the Jumbotron, I constructed my div with an inline background image. However, when I attempted to apply an overlay on to ...

The issue of apples failing to spawn correctly in the Snake game

My Snake game seems to have a bug that causes some strange behavior whenever an apple is collected. Upon collision, the apple disappears and a new one spawns in a new location, but then the original apple reappears in its initial spot. Subsequently, when t ...

Using Jquery and CSS to create a sleek animation for opening a div box container

Designed an animation to reveal a div container box, but it did not meet the desired criteria. Expectations: Initiate animation horizontally from 0% to 100%. Then expand vertically to 100% height. The horizontal animation from 0% to 100% is not visible ...

AngularJS: Understanding the difference between ng-show and using display:none

I recently encountered a scenario where I needed to hide an HTML element by default using CSS. Here's how I did it: HTML: <div class="box"> </div> CSS: .box { display: none; } However, I wanted to be able to show and hide the elem ...

Arranging an image next to a form with rows

Note: Utilizing Bootstrap Framework This is the design I am aiming for: https://i.sstatic.net/vAhzY.png Code: <!DOCTYPE> <html> <head> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"> </head> <style> ...

Would like to conceal an element only if it is currently visible

Currently in the process of developing a website, I have successfully implemented a dropdown menu that is triggered when clicking on an "About Me" link. This reveals additional links such as biography and interests. The issue I am facing now is regarding t ...

Using Javascript to extract and organize JSON arrays from various sets of checkboxes

Is there a way to automatically create an array of multiple groups of arrays like this: arr = {arr1:{index:value, index2:value2}, arr2:{index,value, index2:value2}}; The order is based on groups of checkboxes in HTML (see example below): <div class=& ...

Arranging content within columns according to their column position

As I design a grid with three columns, each grid box contains a div with a maximum width of 280px. Sometimes the grid columns exceed this width. To achieve my desired layout, I aim to align the content in the grid boxes so that the left column aligns to th ...

Determine the point spread using Jquery

Trying to figure out the point spread and determine the winner of a game based on the entered scores. I've created a function to calculate the total number of points and another function to calculate the point spread and assign a winner label. However ...

JS receiving a reference to an undefined variable from Flask

I referenced this helpful post on Stack Overflow to transfer data from Flask to a JS file. Flask: @app.route('/') def home(): content = "Hello" return render_template('index.html', content=content) HTML <head> ...

Accessing JavaScript elements from PHP code

Is it possible to recognize JavaScript elements if they are nested within PHP tags? For example: <?php $username = "maniacal"; echo "<p class='welcome' id='greeting'>Hi, Welcome to the site!!</p>" ?> That's ...