Ensuring consistent width for both tables

How can I ensure that two tables have the same width at all times, even when the Confirmer name is long and causes one table to expand while the other remains the same? Is there a way to keep both tables of equal width in any situation? You can view an example on this JS Bin.

This is the HTML code:

<table>
<tbody><thead><tr><th>1.5 - STATE</th>
  </tr></thead><tr>
<td>
<b>Issued by </b>User Administrator <b>on</b><font face="verdana" size="1" color="red">           24/05/2013 06:43  
</font></td>
</tr>
</tbody></table>

<table>
<tbody><tr>
<th>
Confirmer
</th>
<th>Status</th>
<th>Date</th>
<th>Comment</th>
</tr>

<tr>
<td>Pathak Chankey</td>
<td>
<img src="xyz.png">
</td>
<td>           24/05/2013 06:43  </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Lastname Firstname</td>
<td>
<img src="xyz.png">
</td>
<td>           24/05/2013 06:43  </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>User Administrator</td>
<td>
<img src="xyz.png">
</td>
<td>         24/05/2013 06:43  </td>
<td>&nbsp;</td>
</tr>
</tbody></table>

And here is the CSS code:

thead{
  background-color: grey;
}


table, td
{
  background:#fffAF0;
border: 1px solid black;
border-collapse:collapse;
}

Answer №1

To ensure your tables have a 100% width, simply create a container with a specified width and then apply the 100% width to the tables within it. Here's an example:

div{
  width:500px;
}

table {
  width:100%;
}

<div>
 <table></table>
 <table></table>
</div>

http://jsbin.com/iduciw/32/edit

Answer №2

What is the reason behind not using a single table?

<table>
        <tr>
            <th colspan="4">1.5 - STATUS</th>
        </tr>       
    <tr>
        <td colspan="4"><b>Issued by </b>Administrator <b>on</b><font face="verdana" size="1" color="red"> 24/05/2013 06:43 </font></td>
    </tr>
    <tr>
        <th> Approver </th>
        <th>Status</th>
        <th>Date</th>
        <th>Notes</th>
    </tr>
    <tr>
        <td>Chankey Pathak</td>
        <td><img src="xyz.png"></td>
        <td> 24/05/2013 06:43 </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>Firstname Lastname</td>
        <td><img src="xyz.png"></td>
        <td> 24/05/2013 06:43 </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>Administrator</td>
        <td><img src="xyz.png"></td>
        <td> 24/05/2013 06:43 </td>
        <td>&nbsp;</td>
    </tr>
</table>

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

Trouble with PHP file uploads

Greetings! I am a developer coming from an ASP.NET background, new to PHP. Recently, I transitioned to PHP as I needed to create a website for a friend. However, I encountered a persistent error message while trying to upload music files to a specific fold ...

The issue of the selection option not being cleared after being set to 0 persists in JavaScript

I am facing an issue where I need to reset the select option to `0` when another option is selected. I have tried the code below for this purpose. if (varALPO1MobNum == "0") { var selectElement = $(&apo ...

Making a dropdown menu spin using Jquery and Javascript

I am in need of a unique solution for a dropdown menu that appears rotated 90 degrees anticlockwise. The goal is to have the dropdown select "button" text displayed vertically, with the options sliding out in a similarly rotated, sideways manner featuring ...

Trouble with Bootstrap v4 toggle drop-down menu functionality detected in local environment, yet functions correctly when live on the

Today, I've encountered an issue with my Bootstrap v4 collapsible hamburger menu on my local XAMPP server. Interestingly, the menu works perfectly fine on my public website when the display is 768px wide in Chrome and Firefox. I have searched through ...

Media queries are behaving incorrectly, causing them to trigger when regular CSS should be applied, and vice versa

When I switch to laptop/desktop view, the regular CSS styles are being overridden in the inspect element, and the query styles are taking precedence. Can anyone explain why this is happening? For instance, let's take a look at the code for the nav se ...

The function in_array() in PHP is not functioning as anticipated

I'm currently working on a feature that involves a multiple select drop-down list, and I'm trying to figure out how to display the selected values on an edit form. I seem to be having issues with the in_array() function not behaving as expected. ...

php print some additional php script

I am struggling with implementing PHP code that contains an echo statement. However, I need this echo to output PHP code within it. Here is a brief example: <!php echo '<?php echo "test"; ?>'; ?> The main issue arises when I try to ...

How to position text in the center of a video using CSS

My attempt to center the name of my blog on top of a video background was not successful, even though I tried positioning it absolutely with 50% from the top. Can someone assist me in vertically and horizontally centering the text over the video? Here is ...

Modifying Django: What is the process for altering the HTML representation of a Django form component?

I've got a set of three select drop down boxes for selecting a date of birth. Here's how my Django template displays it: <label>Date of birth</label> {{ reg_form.date_of_birth }} However, I need to customize the HTML structure for e ...

The constricted styles are causing the whole page to bounce (scroll) up and down

On my SPA frontend, I have a parent div with a height of 580 containing 9 smaller divs (about 190px in height each). The parent div has an overflow set to hidden so that only 3 elements are visible at one time. Every 5 seconds, I change the styles by addin ...

Align the image so that it is perfectly positioned along the lower edge of the window

I have been experimenting with parallax scrolling and resizing images using JavaScript. However, I am struggling to align my homepage perfectly with the edge of the window. The code I have doesn't line up with the bottom edge of the webpage. If I us ...

The program is designed to only allow up to two images to be wrapped

I'm struggling with a short jQuery program that I need help with. The problem is, I can't seem to get it to wrap more than two images in the same row. My goal is to create a website that side-scrolls, and I thought this approach would be the simp ...

Is a Responsive Split Layout the Solution for Your Web Design Needs?

I'm looking to create a webpage layout where the left half of the viewport is for Login and the right half is for Signup. This layout should be split side by side on tablets, desktops, and large screens, but stacked vertically (Login on top, Signup on ...

What could be causing the absolute positioned element to not follow the positioning rules as expected?

Currently, I am following a guide on creating a website using Dreamweaver (). However, I have encountered a step in the tutorial that I am struggling to comprehend. The issue lies with an element named #navlink, which is absolutely positioned in the DOM s ...

I am developing a JWT authentication and authorization service for my Angular application. However, I am running into issues when trying to implement observables

I have created a user class and required interfaces as outlined below: user.ts import { Role } from '../auth/auth.enum' export interface IUser { _id: string email: string name: IName picture: string role: Role | string userStatus: b ...

basic php websocket demonstration

Seeking help for implementing websocket functionality. I have been working on a websocket example, but it seems to be encountering some issues that I can't identify. Any assistance would be greatly appreciated. Thank you in advance. Here are the ex ...

Ways to keep images in line instead of moving to a new line

http://jsfiddle.net/KuFbH/ I'm attempting to have all four images displayed on a single line without wrapping to the next line. Strangely, I can't seem to achieve this even though zooming out shows it exactly as desired. How can I make this work ...

Having trouble fixing an ASP Classic Script issue with two unnecessary buttons. The script includes two buttons instead of just one, causing confusion and ineff

Hey there, I've encountered a little issue with the ASP Script and the HTML elements inside the body tags. It seems to be generating two buttons instead of just one, which is not what I intended. My main goal here is to remove one of the buttons so th ...

Various image dimensions cause divs to shift unevenly

Here is the current setup: <div class="row"> <div class="col-md-4 content-column"> <img class="btn-center btn-desktop" src="images/buttons/btn-desktop.svg" alt="desktop button"> <h2 class="btn-deskt ...

HTML min-width is not being considered by the media query breakpoint

After resizing the browser window to less than 480px, my site reverts back to its original style (the css not defined inside the mixins). I attempted to limit the html with min-width, but despite the browser displaying a horizontal scrollbar, the css still ...