Using CSS to create a table with two columns

Greetings! I recently inherited a JavaScript application that includes a search window with the following code snippet.

My goal is to have the text "Statistics Search" positioned above the Statistics label and checkbox. Next, I would like the remaining rows to stack on top of each other with "Estimates Search" at the beginning. Is it feasible to achieve this layout using the existing table structure pTable? I prefer not to delete the table due to its connections to various files.

I attempted to introduce a new div with a width of 50%, but unfortunately, it did not yield the desired outcome. Any insights or guidance provided would be greatly appreciated.

CSS

.pPane {
    float: right;
    clear: right;
    margin-left: 5px;
}
.ptable
{
    float:left;
    margin-top:10px;
}
.pBottom 
{
    float: left;
    clear: both;
    width: 100%;
}

HTML

<div id="pPane" class="pPane">
    <div id="pBottom" class="pBottom">
        <table id="pTable" class="ptable">
            <tr><td colspan="9"><span id="sSearch" style="color:black; font-size:12px; text-decoration:underline;">Statistics Search 
                          </span></td></tr>
            <tr><td colspan="9"><label>Statistics</label></td><td><input id="1" type="checkbox" /></td></tr>
            <tr><td colspan="9"><span id="eSearch" style="color:black; font-size:12px; text-decoration:underline;">Estimates Search</span></td></tr>
            <tr><td colspan="9"><label>Estimate 1</label></td><td><input id="2" type="checkbox" /></td></tr>
            <tr><td colspan="9"><label>Estimate 2</label></td><td><input id="3" type="checkbox" /></td></tr>
            <tr><td colspan="9"><label>Estimate 3</label></td><td><input id="4" type="checkbox" /></td></tr>
        </table>
    </div>
</div>

Answer №1

Could something like this be what you're looking for?

http://jsfiddle.net/GHC7T/3/

In my opinion, using Divs and CSS would yield better results than the current table structure. It's generally not recommended to use tables in this way.

<div id="pPane" class="pPane">
<div id="pBottom" class="pBottom">
    <table>
        <tr>
            <td>
                <table id="pTable" class="ptable">
                    <tr>
                        <td colspan="9">
                            <span id="sSearch" style="color:black; font-size:12px; text-decoration:underline;">
                                Statistics Search
                            </span>
                        </td>
                    </tr>
                    <tr><td colspan="9"><label>Statistics</label></td><td><input id="1" type="checkbox" /></td></tr>
                </table>
            </td>
            <td>

                <table>


                    <tr><td colspan="9"><span id="eSearch" style="color:black; font-size:12px; text-decoration:underline;">Estimates Search</span></td></tr>
                    <tr><td colspan="9"><label>Estimate 1</label></td><td><input id="2" type="checkbox" /></td></tr>
                    <tr><td colspan="9"><label>Estimate 2</label></td><td><input id="3" type="checkbox" /></td></tr>
                    <tr><td colspan="9"><label>Estimate 3</label></td><td><input id="4" type="checkbox" /></td></tr>
                </table>
            </td>
        </tr>
    </table>
</div>

Alternatively, you could consider trying out this http://jsfiddle.net/LDJ2X/3/

<div id="pPane" class="pPane">
<div id="pBottom" class="pBottom">
    <table id="pTable" class="ptable">
        <tr>
            <td>
        <tr>
            <td colspan="2">
                <span id="sSearch" style="color:black; font-size:12px; text-decoration:underline;">
                    Statistics Search
                </span>
            </td>
            <td colspan="2"><span id="eSearch" style="color:black; font-size:12px; text-decoration:underline;">Estimates Search</span></td>
        </tr>
        <tr rowspan="3">
            <td>
                <label>Statistics</label>
            </td>
            <td><input id="1" type="checkbox" /></td>
            <td><label>Estimate 1</label></td>
            <td><input id="2" type="checkbox" /></td>
        </tr>
        <tr></tr>
        <tr>
            <td colspan="2" />
            <td><label>Estimate 2</label></td>
            <td><input id="3" type="checkbox" /></td>
        </tr>
        <tr><td colspan="2" /><td><label>Estimate 3</label></td><td><input id="4" type="checkbox" /></td></tr>
        </td>
        </tr>
    </table>
</div>

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

Place the label next to the input field in a bootstrap form

I have been attempting to code this layout, but I am not achieving the desired outcome. I even tried using inline coding, but that didn't work either. If anyone could help me display the expected output, I would greatly appreciate it. Thank you. < ...

How can I update the value of one select tag when another select tag is changed?

My web page contains two select options as shown below. https://i.sstatic.net/kmDv3.jpg There are two select options labeled as #age1 and #age2, with age values ranging from 18 to 30. I want to ensure that when a user selects an age from #age1, the minim ...

Enhanced Compatibility of HTML5/CSS3 Modal Box with Internet Explorer

I'm experimenting with HTML5/CSS3 for the first time and have implemented a cool little link to display a dialog (modal) on one of my web pages. While this works perfectly in Chrome/Firefox, it unfortunately doesn't function properly in Internet ...

Does the browser detect the HTML version of the document?

I discovered that my HTML 4 document successfully utilized the required attribute from HTML 5, displaying a red error border when an input was left empty. It seems like the browser interpreted the document as HTML 5 and disregarded the DOCTYPE declaration. ...

React-Router Refreshes Component When Moving To Another Route

I am currently in the process of familiarizing myself with React and Redux. My current setup involves the following: Within the store's state, there is a property named 'activeAction' which stores a number value. The 'activeAction&apos ...

Crafting a secretive and subtle side menu that pops out when triggered

My website features a hidden side menu that slides out when the main div is hovered over. The challenge arises when I want the side menu to remain visible when interacting with its elements, while still hiding when both the main div and side menu are not b ...

The functionality of List.js is currently not optimized for use with tables

I'm currently experimenting with list.js in order to create a real-time search feature for a table. I have successfully tested it on lists (similar to the example provided at ). However, I am facing difficulty replicating this functionality for tables ...

Looking for help with Bootstrap - attempting to make a two-column table using list-group-item styling

Novice programmer seeking assistance with bootstrap4. I'm attempting to set up a list group item to showcase user reviews.see image description here I've tried adjusting every possible element. At first glance, it appears straightforward, but ...

What's the best unit of measurement to use when designing a business card online: pixels or cent

Looking for advice on designing business cards online with specific dimensions - 8.5 cm x 5.5 cm. The dilemma lies in choosing between using pixel or centimeter units in CSS for width and height. What's the best approach? Ultimately, I'll need ...

Conceal excess text during auto-scrolling without removing it

I am looking to conceal extra text within a child div without fully deleting it or forcing it into a vertical orientation. I want the excess text to be revealed gradually, similar to how Spotify and Apple Music handle it. My goal is for the red div to act ...

Is it possible to align the last item in a MUI stack to the bottom?

https://i.stack.imgur.com/IsutM.png Currently, I am working on a modal component using MUI's Grid. My goal is to position the Button at the bottom of the modal. const styles = { modalBox: { position: 'absolute', top: &ap ...

Should I use margin-top, padding-top, or top?

I often mix up padding-top, margin-top, and top. My issue arises when I need to create a space of 15px. Using margin-top: 15px seems to work, but I suspect it might be incorrect? .subtitles{ font-size:13px; font-family: "Open Sans","Helvetica Neue", ...

Tips on keeping the size of a react-bootstrap modal constant and enabling scrolling instead of expanding

<Modal size="lg" scrollable show={showInvModal} onHide={handleCloseInvModal}> <Modal.Header closeButton> <Modal.Title>Check out our latest items!</Modal.Title> </Modal ...

One solitary table is successfully loaded

I am facing an issue with my setup where I have two HTML tables and a PHP file that loads every 1 second through AJAX to pass information to these tables. Here is the HTML structure: <div style='float: left;'> <br><br> & ...

issues with re-invoking the button following dynamic addition/removal in Angular 2+

A textbox with add (+) and delete (-) buttons attached horizontally has been created. The first button lacks a delete section. Its image is - https://i.sstatic.net/lwco5.png Due to coding dependency, the add (+) button disappears after the first addition. ...

How can I apply a unique CSS class to specific rows within an h:dataTable?

I am looking to apply unique CSS classes to certain rows within my <h:dataTable>. Is it possible to manipulate and style the individual table rows in a customized manner? ...

What is the best method to make a hyperlink within an IFrame open in a new window?

Let me share the code I've been working on: <!DOCTYPE html> <html> <head> <base target="_blank"> </head> <body> <div style="border: 2px solid #D5CC5A; overflow: hidden; margin: 15px auto; max-width: 800px; ...

Troubleshooting: Jquery UI Draggable - Cursor losing track of draggable element

I want to create a draggable popup with Jquery UI functionality, but I'm facing an issue where the cursor does not stay aligned with the popup element when dragged. When dragging the popup element to the left, the mouse cursor goes beyond the div elem ...

Make sure to verify if the mode in Angular is either visible-print or hidden-print

Here is a snippet of code <div class="row"> <div class="col-sm-12 visible-print"> Content (display in full width when printed) </div> <div class="col-sm-6 hidden-print"> Content (same as above but only half width when ...

What is preventing me from successfully transferring data to a different HTML page?

While I understand that there are numerous questions related to this topic, I believe my situation is unique. I am attempting to transfer form data from one HTML file (test.html) to another HTML file (tut1.html). Essentially, my goal is to extract the dat ...