What is the best way to create an HTML template with a table where the first column is divided into four cells and the second column only has one

Currently, I am working on a template using HTML and CSS. One issue that I am facing involves designing a table template with HTML and CSS.

The specific problem occurs in the second row of the table where there are 4 cells in the first column and only one cell in the second column.

In the first column, the header is 'performance' and the second cell is divided into 4 separate cells.

Meanwhile, the second column has the header 'disciplinary' and only one cell in the second row.

I have been experimenting with different solutions but haven't found the perfect design for this table yet.

One idea I tried was:

<table>
      <thead>
          <tr>
              <th>
                  Performance Rating for
                  last two years
              </th>
              <th>Disciplinary letters (in last two years)</th>
          </tr>
      </thead>
      <tbody>
          <tr>

<td>Year</td>
<td></td>
<td></td>
<td></td>

          </tr>
          <tr>

<td>Year</td>
<td></td>
<td></td>
<td></td>

          </tr>


      </tbody>
  </table>

This is the web design layout desired:

https://i.sstatic.net/tmEaH.png

After updating the post:

Can someone please show me how to achieve this by using colspan and rowspan?

Adjusting the width of the second cell next to the year under the 'performance rating' column is necessary for my requirements.

<table border="1">
      <thead>
          <tr>
              <th colspan="2">
                  Performance Rating for
                  last two years
              </th>
              <th>Disciplinary letters (in last two years)</th>
          </tr>
      </thead>
      <tbody>
          <tr colspan="2">
            <td>Year</td>
            <td ></td>
            <td rowspan="2"></td>
          </tr>
           <tr colspan="2"> 
             <td >Year</td>
             <td></td>
           </tr>
           
      </tbody>
  </table>

Answer №1

I successfully resolved my problem by utilizing col span and row span

Here is the code I used:

<table border="1">
      <thead>
          <tr>
              <th colspan="2">
                  Performance Rating for
                  last two years
              </th>
              <th>Disciplinary letters (in last two years)</th>
          </tr>
      </thead>
      <tbody>
          <tr colspan="2">
            <td style="width:50px;">Year</td>
            <td ></td>
            <td rowspan="2"></td>
          </tr>
           <tr colspan="2"> 
             <td style="width:50px;">Year</td>
             <td></td>
           </tr>
           
      </tbody>
  </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

Determine the number of elements chosen within a complex JSON structure

I need to figure out how to count the length of a jsonArray, but I'm stuck. Here's an example to start with: https://jsfiddle.net/vuqcopm7/13/ In summary, if you click on an item in the list, such as "asd1", it will create an input text every t ...

Integrating a fictitious style using jQuery

Having some trouble with this code snippet. The issue arises when trying to apply the following style using jQuery. CSS .arrow_box { position: absolute; width: 24px; border-radius: 30px 30px 3px 3px; height: 17px; float:left; } .arrow_box:after { bord ...

Encountering a syntax error while trying to upload a file due to an unexpected end of file

When attempting to upload files from a form page, only one file shows up on the database online and in the folder. Here is the code from the form page: <form method="post" action="post_data.php" enctype="multipart/form-data"> <table align=" ...

Exploring the concept of data sharing in the latest version of Next.JS - Server

When using App Router in Next.JS 13 Server Components, the challenge arises of not being able to use context. What would be the most effective method for sharing data between various server components? I have a main layout.tsx along with several nested la ...

Tips for customizing the appearance of a specific mat-button component in an Angular project

In my Angular application, I have set up a scenario where users are presented with multiple choices through buttons. When a user clicks on a button, a specific component is displayed based on their choice. I am currently working on enhancing the styling of ...

The aspect ratio of an image is being calculated by loading the image twice

I am currently facing the issue where the same image is loading twice for a single preview. The first time the image is loaded for preview purposes in an iframe. The second time, the image metadata such as width and height are fetched with the same path. ...

Modify the button text when it is hovered over

I am attempting to modify the text displayed on a button when hovering over it in a React component from Ant Design. However, I have not been successful so far. Button <div className={ status == "verified" ? `${styles.btn1} ${styles.btn1C ...

Express and Webpack Error: "SyntaxError: Unexpected token <"

I am facing difficulties while testing my React webpage that I built using Webpack. When trying to run an Express server, the localhost page appears blank with a console message saying Uncaught SyntaxError: Unexpected token <. It seems like the webpage ...

Json Swagger Editor: Error - Undefined

There is an undefined error in rendering when using the Swagger Editor. Here is the code snippet: swagger: '2.0' info: version: 1.0.0 title: AccountBalance host: localhost:2625 basePath: /accountbalance schemes: - http - https consumes: ...

Display Vue component depending on specified attribute

I have a block of code that I am working with: <div> <b-card no-body> <b-tabs pills card vertical no-key-nav v-model="step"> <b-tab title="Subject" v-for="animal in animals" :key="animal&q ...

Passing an HTML5 video element as a prop in Vue.js

I am attempting to pass an HTML5 video as a property from a parent component to a child component in Vuejs. Parent Component: <template> <div> <video ref="video"> <source src="@/assets/video.mp4" type= ...

How to implement setState within a Promise function using useEffect in React functional components with hooks?

I am struggling to set the value of a hook within a Promise function inside a useEffect(), and then store the returned promise value in the fruit hook so that it can be accessed in the return function of MyComponent() This is what I have attempted so far: ...

Adjust the alignment of the text to match the orientation of the image

When creating a layout with text and an image, I want them to be contained within a parent element that has a specified height, such as 100px. The text should adjust to the content, whether it's a short phrase or a lengthy paragraph, without a fixed ...

The challenge with the Optional Chaining operator in Typescript 3.7@beta

When attempting to utilize the Typescript optional chaining operator, I encountered the following exception: index.ts:6:1 - error TS2779: The left-hand side of an assignment expression may not be an optional property access. Here is my sample code: const ...

Utilizing Ajax and Spring MVC to Update a Single Row in a Table with JQuery

Hey there! I'm encountering a 400-BAD REQUEST error with my AJAX CALL code below. In the snippet provided, you'll find a table where all Student records are displayed, including roll number, first name, last name, and address, along with edit an ...

What is the best way to align my logo image and search field at the center of the page, similar to the layout of

Struggling with styling this webpage. I aim to have my logo and search bar centered on the page, surrounded by ample space above and below. You can check it out at NE1UP dot com. All I want is a Google-style layout for my page, but I'm facing difficu ...

Encountering errors during the installation of packages using npm

Can someone please assist me with fixing these errors? I am a beginner in the world of web development and encountered this issue while working with react.js and setting up lite-server. Any guidance on how to resolve it would be greatly appreciated. ...

Issue with deploying NEXT.JS due to a failure in the build process caused by next lint

Issue I have been encountering deployment failures on Vercel due to lint errors in test files within my git repository. Despite following the recommendations from the Vercel documentation for ESLint settings, the issue persists. According to Vercel' ...

JavaScript failing to retrieve JSON information from PHP

I seem to be encountering an issue when trying to read JSON data that I create in PHP and send back to my JavaScript. The problem is puzzling me. Here's the PHP code: header("content-type: text/json"); curl_setopt($ch,CURLOPT_URL, $url); curl_setop ...

Enforcement of Typescript Field Type Lax During Assignment

My current issue involves a constructor that is supposed to set the value of _device. The field is specifically designed to be of type number, and the constructor parameter is also expected to be of type number. However, when a parameter of type string is ...