Alignment Issue in Table Columns

Check out this code snippet (http://jsfiddle.net/HaLGr/11/):

.head_row {
    color: #FFFFFF;
    background-color: #5D7B9D;
}
.row_one {
    font-size: 12px;
}
.row_two {
    font-size: 12px;
    display: none;
}
.row_three {
    font-size: 12px;
    display: block;
}


<table name="main_table" id="main_tbl">
    <tr>
        <td class="head_row">Column 1</td>
        <td class="head_row">Column 2</td>
    </tr>
    <tr class="row_one">
        <td>Row One</td>
        <td>Row One</td>
    </tr>
    <tr class="row_two">
        <td>Row Two</td>
        <td>Row Two</td>
    </tr>
    <tr class="row_three">
        <td>Row Three</td>
        <td>Row Three</td>
    </tr>
</table>

What causes misalignment of the cells in the third row when using display: block ?

I want to be able to hide (display: none) and show (display: block) the table rows with proper column alignment.

Answer №1

Typically, rows are styled with display: table-row; as defined by the browser's default stylesheet, which differs from display: block.

To properly style rows in your CSS, consider using:

.row_three {
    font-size: 12px;
    display: table-row;
}

Answer №2

Avoid using "display: block" in conjunction with tables. It is recommended to avoid using tables altogether for your task and instead consider utilizing DIVs.

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

Error: The function $(...).tableDnD is undefined and cannot be executed

Recently, I've been working on creating a drag and drop gridview using C#. After searching for some jQuery libraries like tableDnD and following various examples, I came across a piece of code. When I tried to implement it with my own code, I encounte ...

Is it acceptable to conceal items by utilizing display:none?

When dealing with a dynamic website that includes components from various plugins, is it acceptable to hide elements temporarily or permanently using display:none? Sometimes clients may request certain items to be hidden from the page, so instead of removi ...

Utilizing a child component in React to trigger a function on its sibling component

Trying to put this question into words is proving to be a challenge. I am wondering in React, if there is a way for a child component that is deeply nested (2 levels deep from the parent) to trigger a function on another component that it has a sibling rel ...

How can I connect a click event on one div to trigger another using jquery?

Could someone assist me with the proper terminology? I am interested in clicking one div, which would then automatically trigger the click on another div. For example, if I click on div 1, I want div 2 to be clicked by JavaScript without user interaction ...

Generate a novel item by organizing the key of an array of objects

I have an array of objects containing various items: [ { CATEGORY:"Fruits" ITEM_AVAIL:true ITEM_NAME:"Apple" ITEM_PRICE:100 ITEM_UNIT:"per_kg" ITEM_UPDATED:Object ORDER_COUNT:0 }, { CATEG ...

dual slider controls on a single webpage

I am attempting to place two different sliders on the same page. When I implement the following code for one slider, it functions correctly: <h3>Strength of Belief</h3> <div class="slidecontainer"> <div class="slider_left"> < ...

Experiencing difficulties in updating the Express page

Encountering an issue with page refreshes, I'm struggling to make it work smoothly. The process begins with filling out a form on an HTML page, which then posts to an API on a different service using the Node RequestJS module. After the post, the othe ...

Utilizing CSS to incorporate a background image into HTML code

Is it feasible to utilize pure HTML for the background-image property? Consider the following scenario: The original: background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height=&apo ...

Use Jquery to replace the text inside a <span> element based on the value selected in a dropdown menu

Struggling with JQuery errors despite my efforts to update input values using a basic function. However, I now face the challenge of simultaneously updating text within an area based on dropdown selections. The provided Script and HTML are as follows: $ ...

CSS is currently unable to render text overlay on the screen

I've been working on implementing this code snippet into my website, but for some reason it's not displaying correctly. I'm using the exact same code that's available on this fiddle: http://jsfiddle.net/2tPGy/3/ Here's the HTML: ...

Fetching data using ng-model along with appending in Javascript

When I press the add button in my form, I want to extract the value from the input field named Name using ng-model. Additionally, I am utilizing the append function in my form to insert the next column. Unfortunately, I have encountered difficulties in imp ...

Personalize the start and end dates of Fullcalendar

While working with fullcalendar, I have a unique requirement. I want my days to start at 5:00 and end at 5:00 the next day. Is it feasible to achieve this customization? ...

What are some methods for deactivating linked clicks while activating alternative links?

I am trying to prevent a link from being clickable after it has been clicked. Here is the code I have: <a class="cmd-7" href="?cmd=7" style="color:#00F; margin-left:15px; text-decoration:underline">Past 7 Days</a> <a class="cmd-14" href="? ...

Background with borders full of parallax effects scrolling in sync

I'm completely new to the world of HTML and CSS, and I was hoping for some guidance. I've been trying to wrap my head around a tutorial on creating parallax scrolling websites, which you can find here: However, I noticed that the tutorial includ ...

Tips for ensuring that text matching does not generate false positives

Here is the code snippet I am currently using: if (URL.toLowerCase().match(/\.(gif)/g)) { alert('gif'); } if (URL.toLowerCase().match(/\.(gifv)/g)) { alert('gifV'); } The issue I'm experiencing is that when the ...

Ways to troubleshoot and verify values in PHP that are sent through AJAX

In my jQuery function, I am using AJAX to send values to a PHP file: $.ajax({ //make ajax request to cart_process.php url: "cart_process.php", type: "POST", dataType: "json", //expect json value from server data: { quantity: iqty, ...

Place the application bar at the bottom of the screen

https://i.sstatic.net/0B0Ad.png I am working on a project aimed at monitoring employees, and I have developed a user interface that allows for modifications within the site. However, there is an issue with the "bottom App Bar" section at the bottom of thi ...

Problem with exporting SQL Server table to Excel

Currently, I am running a setup with 64-bit Windows Server 2008, SQL Server 2008, VS2008, C#, .Net 2.0, IIS 7.0, and ASP.Net. While trying to execute the code snippet below, specifically when accessing an aspx page, I encountered the following error mess ...

The functionality of Javascript Array.splice suddenly malfunctioned in my Angular application

While working on a project in Angular 4, I encountered a situation where I needed to batch through an array of ids. I would send the removed items to an Observable function, and upon the subscription returning, I would check the remaining array before loop ...

Adjusting the layout of columns in Bootstrap 3

I have been attempting to realign columns in bootstrap, but without success so far. In desktop view it looks fine as seen here. However, when the size is condensed, it appears like this tablet view. My goal is to swap the positions of the owner gateway col ...