What can be done to enforce the already set fixed height of a td cell in CSS when it is not being respected?

Upon running the example below, you may notice that the height of the cells varies slightly in each row. Ensuring uniform cell height despite different content is a requirement.

Despite setting height: 1.7em;, it appears to be disregarded. How can this be rectified?

#cert_legend {
    border-collapse: collapse;
    margin-bottom: 30px;
    
}

#cert_legend th, #cert_legend td {
    border: 1px solid #000;
    border-collapse: collapse;
    font-size: 8pt;
    padding: 2px;
    overflow: auto; 
    height: 1.7em;
    max-height: 1.7em;
}

#cert_legend tr>th {
    text-align: center;
}
.cert_description {
    max-width: 200px;
}
<table id="cert_legend">
  <tbody>
    <tr>
      <th colspan="4">Test Variable Legend</th>
    </tr>
    <tr>
      <td class="cert_title">time</td>
      <td class="cert_description">Minutes elapsed</td>
      <td class="cert_title">DPDsn</td>
      <td class="cert_description">Tested differential pressure vs duty point at design RPM</td>
    </tr>
    <tr>
      <td class="cert_title">tw</td>
      <td class="cert_description">Water temperature</td>
      <td class="cert_title">Torque</td>
      <td class="cert_description">Pump torque</td>
    </tr>
    <tr>
      <td class="cert_title">pfin</td>
      <td class="cert_description">Feed pressure in. This is a relative reading to tank pressure</td>
      <td class="cert_title">Eff</td>
      <td class="cert_description">Pump Efficiency</td>
    </tr>
  </tbody>
</table>

Answer №1

To properly display content in a table cell, you can add a div inside the td element with a fixed height and set the overflow property to auto.

td {
    border: 1px solid #000;
}

td > div {
    height: 1.7em;
    overflow: auto;
}
<table>
    <tr>
        <td>
            <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Totam, fugiat delectus explicabo natus tempore, officiis quas in eius dolore cumque non iste eveniet necessitatibus, inventore odio cupiditate consequuntur quis mollitia.
            </div>
        </td>
    </tr>
</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

Responsive design for iPads and smartphones is essential in ensuring a seamless user

Currently in the process of creating my own personal website, I have been diligently using Chrome Canary to ensure that all my media queries are properly set up. While everything looks great on Canary and functions well in various device modes within the b ...

Internet Explorer and Edge browsers are concealing box shadow behind the parent div

When using an input slider range, the box-shadow is being applied to the active thumb in all browsers except for IE & EDGE. In these browsers, the shadow is cutting or hiding behind the parent div #c. I have already tried setting overflow:visible on the p ...

I'm looking for recommendations on the best technologies to implement in a location-based mobile app. Any suggestions

Currently working on a server-side website tailored for mobile devices. My main objective is to create a member system where users can log in and share their geolocation data. Once logged in, the user's geolocation information will be stored in my dat ...

Image in an Outlook email surrounded by padding and enclosed in a paragraph

I am facing an issue with my email signature setup in Outlook Live where there is a white space below the image. After trying to add vertical-align:bottom to the CSS, it seems that Outlook Live does not accept it. The code for my HTML in Outlook 20xx is a ...

Select either one checkbox out of two available options

My form includes two checkboxes, allowing users to click on both of them. I'm wondering if it's possible to set it up so that only one checkbox can be selected at a time. For example, clicking on the first checkbox would turn it on while turning ...

Upon submission, the input value undergoes a replacement

Currently, I am working on a PHP file that enables users to choose conditions for a search page. Once the data is submitted using the post method, the user is directed to the search result page. I anticipate that users might want to return to the "select c ...

Is there a way to decrease the speed of a text when hovering over it?

Is there a way to create a button that displays text before another text only on hover, with a delay? I've managed to achieve the effect but can't figure out how to slow it down. For example, notice how quickly the word "let's" appears when ...

What is the best way to adjust the color of the colon within my timer digits using a span element?

I am facing an issue with my timer where the span that was created to display a colon between the numbers does not change color along with the timer digits. I attempted using var colon = document.getElementById(":"); but it still did not work as expected. ...

Adding the header.php file in WordPress caused the style.css to stop working

Whenever I include a basic "header.php" file in my theme directory, my style.css mysteriously stops working. But when I remove the "header.php" file, everything goes back to normal. How can I troubleshoot this issue? Below is the code snippet from my fil ...

Using jQuery to set menu active states for a sprite-based navigation with distinct class names

I'm curious about how to accomplish this using JQuery. I have a menu where each item must have a unique class name in order for the CSS to properly display a sprite background position shared by all items. When an item is clicked, I also need to activ ...

Styling with CSS using only numerical values

My website features a section that states "Weekdays 10:00 ~ 18:00 /*linebreak/ Saturdays 10:00 ~ 13:30" I am looking to format only the numerical values in the font "Courier New," specifically the "10:00 ~ 18:00" and "10:00 ~ 13:30" sections. The remainin ...

Understanding the user's preference for text alignment and managing how the text is displayed in a text area (or text field) within a ReactJS application

My latest project is an app that features multiple text areas. Personally, I use the app with two languages - English and another language that is aligned to the right. However, the default setting has the text-areas aligning to the left. To change this ...

Layer divs on top of each other without explicitly defining their stacking order

I am looking to stack multiple tile divs on top of each other by using negative margin-right: -10px. My goal is to have the previous div displayed on top, with new sibling divs appearing below it. Currently, the newer div overlaps the previous one. While ...

The event listener function is not functioning properly on images generated by JavaScript

I'm currently working on placing multiple images on a grid in the center of the page and would like to include a function that triggers when each individual image is clicked. The images are dynamically created using JavaScript and inserted into the do ...

Changing the orientation of a dropdown menu from horizontal to vertical

Hello, I am seeking assistance to transform the top dropdown menu layout into a vertical one similar to the menu on the left side. Any help would be greatly appreciated as I am running out of ideas! Thank you in advance! @charset "utf-8"; /* CSS Docum ...

Using XSLT to assign a variable with a node value depending on whether or not the node is present

Currently, I am struggling with assigning the value of one variable to another variable in XML based on the presence of a certain node. I have the XPaths for both nodes. Below is a snippet of the XSL code I am working with: <?xml version="1.0" ...

Choose Select2 to remove all selected options

I'm looking for a way to remove all selected values in one click without having to specify each individual 'id' separately. I've tried experimenting with different approaches, but so far, I've only been able to deselect the first ...

Utilizing jQuery or Javascript to obtain the title of the current webpage, find a specific string within it, and then apply a class to the corresponding element

Let's imagine I start with this: <title>Banana</title> and also have some navigation set up like this: <ul id="navigation"> <li> <a href=#">Banana</a> </li> </ul> Upon loading the sit ...

Using .float-right and .float-left within a .row in bootstrap 4 does not achieve the desired result

When using Bootstrap 4, the float property may not work as expected inside a row. I am trying to have the right div appear on the left and the left div appear on the right, but in responsive view I want the right div to be displayed before the left div. ...

Code Not Functioning on Website Despite Working in Console

I've developed a jQuery script that eliminates any delivery methods containing the phrase "Royal Mail" if certain products are present in the user's cart. The script functions flawlessly when executed in Google Chrome Console but fails to work wh ...