Displaying a block of three cells requires the removal of any spacing between them

Click here to view the code

<table cellspacing="1" width="50%" bgcolor="#cccccc">
     <tr class="csstextheader">
     <td>   
     </td>
     <td>Class  
     </td>
     <td>Numbers
     </td>
     </tr>
   <tr class="csstablelisttd">
     <td> 1  
     </td>
     <td>2  
     </td>
     <td>3
     </td>
     </tr>
      <tr class="csstablelisttd">
     <td>  4
     </td>
     <td class='csstdred' > 
     </td>
     <td> 6  
     </td>
     </tr>   
      <tr class="csstablelisttd">
     <td>  7 
     </td>
     <td class='csstdred'>  8
     </td>
    <td>   9
     </td>
     </tr>  
      <tr class="csstablelisttd">
     <td> 10
     </td>
     <td class='csstdred'>
     </td>
    <td>12
    </td>
     </tr>      
   </table> 

The task at hand is to eliminate borders from cells with the csstdred class and display them as a block of three cells without any rowspans.

Answer №1

Try using this CSS:

table {border-collapse: collapse;}

View the working example here: http://jsbin.com/ogusaq/1/edit


Update #1:

To include other borders as well, use the following code:

table {border-collapse: collapse;}
td {border: 1px solid #ccc;}
.csstdred {border-color: #f00;}

Updated Fiddle: http://jsbin.com/iwenuw/1/edit

See the Screenshot Below:


Update #2:

If you only want a specific table to be affected, assign the table a class called .redborder:

table.redborder {border-collapse: collapse;}
table.redborder td {border: 1px solid #ccc;}
table.redborder .csstdred {border-color: #f00;}

Fiddle for Reference: http://jsbin.com/ujabav/1/edit


Update #3:

If you wish to change the color to blue when the .csstdred element is clicked, JavaScript is required. Here's the code snippet:

$(document).ready(function(){
  $(".csstdred").click(function(){
    $(this).toggleClass("active");
  });
});

Add this CSS for the active state:

table.redborder {border-collapse: collapse;}
table.redborder td {border: 1px solid #ccc;}
table.redborder .csstdred {border-color: #f00;}
table.redborder .csstdred.active {border-color: #00f; border-width: 2px 1px 1px 2px; border-collapse: separate;}

Interactive Example: http://jsbin.com/ihejep/1/edit


Update #4

table.redborder {border-collapse: collapse;}
table.redborder td {border: 1px solid #ccc;}
table.redborder .csstdred {border-color: #f00;}
table.redborder .csstdred div {border: 1px solid #f00;}
table.redborder .csstdred.active div {border: 1px solid #00f;}

Additional JavaScript Functionality:

$(document).ready(function(){
  $(".csstdred").wrapInner("<div>").click(function(){
    $(this).toggleClass("active");
  });
});

Updated Example: http://jsbin.com/abekup/1/edit

Explore More Options in This Updated Version: http://jsbin.com/abekup/5/edit

Answer №2

Modify the tb tag to div in a specific location.

    <td colspan="4" class="custombg">
    <div><p>2</p><p>2</p><p>2</p></div>
    </td>

Answer №3

Only altered the HTML without any changes in CSS.

Please review the updates on this link

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

Sorting items within an iFrame using jQuery Sortable

My iFrame contains jQuery sortable content. Everything is coded and working correctly, but when I try to drag an item to rearrange it, the mouse stops functioning until I move outside of the iFrame. At that point, the item is left in a dragged state. How ...

confirming the phone field's character count

My website has multiple phone fields, each formatted like this: $("#HomePhoneInput").inputmask({ "mask": "(999) 999-9999" }); $("#WorkPhoneInput").inputmask({ "mask": "(999) 999-9999" }); $("#CellPhoneInput").inputmask({ "mask": "(999) 999-9999" ...

Unleashing the Power: Crafting Impeccable For Loops

After running the select query in the "get-employee.php" page, I obtained the answer for this page. Then, I returned the data to the previous page (home.php). On this page, I added a for loop in JavaScript before the tag with the class "col-md-3". Within t ...

Add an image to a container

I am facing an issue with my code that fetches photos from a flickr feed using JSON and appends them to a div inside another div. Currently, all the images are being appended into one div, but I want each image to be appended to a separate div. $.getJSON( ...

What is the best way to divide widgets in a Wordpress Sidebar?

I am looking to customize the spacing between widgets in my Wordpress sidebar, similar to what is shown on this example site. Currently, my sidebar does not have the desired spacing. I have tried various CSS codes found online, but none of them seem to be ...

Issues with CSS functionality

Every now and then, this thing decides to work but most of the time it just doesn't. I have multiple tables in my application and the CSS is functioning properly for all of them. There's literally no difference with this one table, yet the CSS re ...

Submitting Forms Across Domains in Internet Explorer

I have a lead form on my website that is connected to the Zoho CRM system. When I submit the form using Ajax, it works perfectly in all browsers except for Internet Explorer. Here is the code that I am currently using: $.ajax({ type: ...

accessing HTML form via XMLHttpRequest (XHR)

One challenge I'm facing is retrieving form content using XmlHttpRequest, but it doesn't seem to post anything on the subsequent page. If I include the form within the same page where my script is used, it does post data. However, the informatio ...

How can I use Selenium and Python to locate an element on a webpage and extract its input value?

I'm currently working on a specific part of the website and I'm trying to extract the value from . I know how to access the span class using best_offer = driver.find_element_by_class_name('showBestOffer') in Selenium, but I'm wonde ...

Display the definitions of entities within the titles of div elements

Within a React application, this block of HTML is present: <div className="my-class" title={myValue}> <div>{myValue}</div> </div> The value of myValue is MyCompany™. The inner div displays the content correctly. Ho ...

If the sidebar is not found on WordPress, delete the CSS code

This situation seems a bit strange when it comes to applying a background color. Here is the main structure: <section class="main-row"> <div class="container"> <div class="row"> <div id="primary" class="col-sm- ...

utilizing a Bootstrap modal element throughout multiple HTML documents

I have a bootstrap modal dialog div that I want to use in all 4 html pages of my web application without repeating the code. I have a common JavaScript file for this purpose. What is the best way to achieve this? <!-- Modal --> <div class="modal ...

Choosing a dropdown option with a CSS Selector

Here is the code snippet I am currently working with: import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.o ...

Show JSON response using AJAX jQuery

After receiving the JSON Response, { "user_data": { "id": 22, "first_name": xxx, "last_name": xxx, "phone_number": "123456789", }, "question_with_answers" : [ { "id": 1, ...

Issue with mix-blend-mode causing text to not show up on top of the gradient

I am struggling to find a way to make text easily readable over my gradient background. Despite trying to use MUI's Typography or a simple <p>, the contrast isn't great as the text appears in black. After some research, I discovered that I ...

Applying flexbox to create a visually appealing design

Is there a way to achieve this layout using flexbox without relying on grid due to limited support in IE11? I want to be able to easily add or remove small divs without adding more containers. To see the desired layout, check out this image: Desired Layou ...

My subsequent page is getting erased by these dynamic page loads

I am encountering an issue with loading multiple pages. I have five separate pages that I want to load, each containing two dynamic loads to swap out the content of some divs. Everything works fine until I introduce the loading of the HTML page that will b ...

Troubleshooting CSS Hover Not Displaying Properly in Angular 14

In the footer class of my HTML, there is a code snippet with chevrons: <div class="link-list"> <div *ngFor="let link of insideLinksLeft | originalOrderKeyValue" class="link"> <a [href]="link.val ...

Don't forget to update the CSS stylesheet whenever templates are rendered in Flask

I have developed a Flask application using HTML and external (static) CSS stylesheets. One interesting feature of the application is a checkbox that uses JavaScript to toggle between two different CSS stylesheets - one for light mode and one for dark mode. ...

Using JQuery to switch out images that do not have an ID or class assigned

Currently, I am using a Google Chrome Extension to apply an external theme to a website. Unfortunately, the logo on the site does not have an ID or class that can be used to call it. I am searching for a solution to replace it with a different image. My ...