Guide on building a table with colspan, rowspan, or css in HTML

https://i.sstatic.net/9y07i.jpg

Is there a way to create a table similar to the one shown above using only HTML and CSS? I've attempted the code below:

<table>
    <tr>
    <th>XXX</th>
    <th>XXX</th>
    </tr>
    <tr>
    <td>XXX</td>
    <td>XXX</td>
    </tr>
    <tr>
    <td>XXX</td>
    <td>XXX</td>
    </tr>
    <tr>
    <td>XXX</td>
    <td>XXX</td>
    </tr>
</table>

Unfortunately, my attempts have been unsuccessful. Can anyone offer assistance?

Answer №1

Here is an example:

<table border="1" cellpadding="10" cellspacing="0" style="width:100%">
  <tr>
    <td style="width:50%">&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td rowspan="2">&nbsp;</td>
    <td>&nbsp;</td>
    <td rowspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td rowspan="2">&nbsp;</td>
    <td>&nbsp;</td>
    <td rowspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>

Answer №2

<table>
<tr>
<th colspan="2">AAA</th>
<th colspan="2">BBB</th>
</tr>
<tr>
<td colspan="2">CCC</td>
<td colspan="2">DDD</td>
</tr>
<tr>
<td colspan="2">EEE</td>
<td rowspan="2">FFF</td>
</tr>
<tr>
<td colspan="2">GGG</td>
<td>HHH</td>
</tr>
<tr>
<td colspan="2">III</td>
<td rowspan="2">JJJ</td>
</tr>
<tr>
<td>KKK</td>
<td>LLL</td>
</tr>
<tr>
<td colspan="2">MMM</td>
<td rowspan="2">NNN</td>
</tr>

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

Updating the default color of selected text within a webpage's content

Is there a way to modify the default blue color that appears when content is selected on a webpage? I am wondering how to change this selection color to a custom color of choice. ...

Is there a way to retrieve all div elements within a specific div using webdriver and selenium?

As a newcomer to the world of web scraping, I am currently working on scraping a website in order to extract all elements with the data-feature-id=homepage/story. My ultimate goal is to access a subelement within each of the divs contained in the parent el ...

Capture an image from the webcam without any manual intervention and store it in the system's directories

Looking to automate the process of capturing a picture from a webcam once access is granted, and then saving it without any user intervention. I've managed to capture the image but struggling with: A) Automating the capture process B) Saving the ca ...

What is the best way to incorporate background colors into menu items?

<div class="container"> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-12 fl logo"> <a href="#"><img src="images/main-logo.png" alt="logo" /> </a> ...

Utilizing Node.js and Express.js to Parse HTML Form Inputs

Having trouble extracting input from an HTML form and utilizing it in Node.js. Here is the HTML form being used: <form action="/myform" method="POST"> <input type="text" name="mytext" required / ...

Uninterrupted movement within a picture carousel

Seeking a way to create a smooth transition in an image slider with sliding dividers using continuous switching when clicking previous/next buttons. Currently, the dividers replace each other from far positions. Any ideas on achieving a seamless single mov ...

What specific measurement does a font-size in pixels correspond to?

Many software programs and systems allow users to specify font size using pixel height, such as Photoshop and CSS. But what does this measurement actually refer to? Is it the distance from the descender to the ascender? Or perhaps from the baseline to the ...

Changing the Displayed Content with a Simple Click of a Link

Layout Overview In the process of developing a tool to streamline work tasks, I want to ensure that I am following best practices. My goal is for the website to initially display only column A, with subsequent columns generated upon clicking links in the ...

Is it possible to conceal or disregard text elements from the web browser search function by using CTRL+F?

I have a complex web application interface with a dedicated area for content display. Is there a way to ensure that when users utilize the browser's text search function (CTRL+F), the UI elements are ignored and only the actual content is searched? ...

Script on Tampermonkey executed prior to page loading

I am facing a challenge with hiding a specific section from an HTML page: <h1 data-ng-show="!menuPinned &amp;&amp; !isSaaS" class="logo floatLeft" aria-hidden="false"><span>XXX&nbsp;</span><span style="font-weight: bold;"& ...

Hover Image Grid

Having trouble with creating an image grid that displays text on hover? Check out the issue I encountered with my layout: https://i.sstatic.net/PVDzB.jpg For some reason, the text is not aligning properly on the image, causing a layout problem. Any assist ...

Maximizing the Potential of Bootstrap 5's Grid System

I'm struggling a bit with the Bootstrap grid system. I want to create 6 divs or containers that span the full width on smaller devices like mobiles, use 25% of the width on medium devices like tablets, and display all 6 in a single row on large deskto ...

Using jQuery to switch between different content divs

I'm trying to create a script that allows users to toggle between different posts, showing one at a time. However, I'm running into an issue where clicking on a new post doesn't hide the content of the previous one. How can I modify the code ...

When the source is added with jQuery, the IMG element displays at 0x0 pixels

My latest project involved creating a custom modal popup named #light1. In my JavaScript code, I capture the source from the image the user clicks on and insert it into the img tag with the id of addable. Using jQuery: var images=$('#raam img') ...

What is the best way to place two input fields side by side within a table cell so that they each occupy 50% of the width?

Looking for some table help here: <table> <tr> <td> <input type="text" class="half"/> <input type="text" class="half" /> </td> <td> <input type="text"/> </td> &l ...

Leveraging jQuery for Adding Text to a Span While Hovering and Animating it to Slide from Left to

<p class="site-description">Eating cookies is <span class="description-addition"></span>a delight</p> <script> var phrases = new Array('a sweet experience', 'so delicious', 'the best treat', ...

Is it possible to reorganize several divs for mobile screens?

My setup is quite intricate. I have a layout with 2 rows consisting of three divs each on larger screens. It looks something like this: <div class="row row-1"> <div class""square">square 1</div> <div class"&qu ...

Position the div element below the navigation bar

I am attempting to embed a Leaflet map within a standard Sails.js view. Sails.js automatically includes a page header on every page. Currently, with a fixed height, the map appears like this: #mapid { height: 400px; } https://i.sstatic.net/pzOdql.jpg ...

What's the best way to show black text for progress between 0-40% and white for progress between 60-100%?

As a beginner, I humbly ask for your forgiveness. My goal is to show progress percentages in black and white based on the progress state. Despite my attempts with if statements and creating new classes for black and white progress states, I have not been s ...

Issue with implementing jQuery tab functionality

I'm just starting to learn JS, HTML, and CSS, and I could use some guidance on setting up jQuery tabs. Currently, I'm encountering an error that says "Uncaught TypeError: $(...).tabs is not a function". Any help would be greatly appreciated. Than ...