Adjusting the width of individual cells or columns within a table through my HTML code is proving to be a challenge

I am struggling to adjust different column widths in my table. Despite trying various approaches, such as changing the width of specific td/th elements and using inline styling or nth-child property, I have been unsuccessful in altering the width. The table div also includes overflow properties which further complicates matters. Can someone please assist me in resolving this issue?

  <!DOCTYPE html>
  <html>
  <head>

    <style>
.table-div
{
  overflow-x:auto; 
  overflow-y:auto; 
  margin-bottom: 100px;
   margin-top: 100px;
  max-height: 300px;"
  border: 2px blue;
}
.lesswidth
{
  width: 500px;

}
.fixedwidth
{
  width: 150px; 

}
table {
  /*table-layout: fixed;*/
 /* width: 100%;*/
 /* max-height: 100px;*/
  /*border-collapse: collapse;*/
  border-spacing: 0;
  border: 1px solid red;
  display: block;
  /*margin-bottom: 100px;*/
}

th{
  /*display: block;*/
   border: 1px solid red;
   position: sticky;
   top:0;
  text-align: left;
  padding: 10px;
  color:black;
  width: 200px;
  background-color: #f2f2f2;
}

td{
  /*display: block;*/
   border: 1px solid red;
  /*text-align: left;*/
  padding: 10px;
  color:black;
  background-color: #f2f2f2;
 width: 200px;
  /*margin: 100px 0px 75px 100px;*/
  /*margin-right: 100px;*/
}


/*td:nth-child(2) { width: 100px !important; }

tr:nth-child(even){
  background-color: red !important;*/
}

/*tr:nth-child(even){background-color: #f2f2f2}*/
</style>


    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="resCSS.css">

  
    </head>


  <body>

  <div class="container">
 
 <div class="table-div">
  <table> <!-- class="tablecolor" -->

    <tr>
      <th class="fixedwidth">NUMBER</th>
      <th>TYPE OF VACCINE</th>
      <th>RELATED USECASE</th>
      <th>DEVELOPER/RESEARCHER</th>
      <th>CURRENT STAGE</th>
      <th>FUNDING SOURCES</th>
      <th>CLINICAL TRIALS</th>
      <th>ANTICIPATED NEXT STEPS</th>
      <th>PUBLISHED RESULTS</th>
      <th>SOURCES</th>
    </tr>


   <tr >
           <td width="500">1</td>
          <td >DNA plasmid; INO-4800</td>
          <td >Same platform as vaccine candidates for Lassa, Nipah, HIV, Filovirus, HPV, cancer indications, Zika, and Hepatitis B</td>
          <td >Inovio Pharmaceuticals/Beijing Advaccine Biotechnology</td>
          <td >Pre-clinical</td>
          <td >Coalition for Epidemic Preparedness and Gates Foundation</td>
          <td >N/A</td>
          <td >Started Phase 1 April 2020; initial data expected late summer 2020</td>
          <td >N/A</td>
        <td >World Health Organization, MarketWatch, BioAegis Therapeutics, INOVIO</td>


    <tr>
  
  </table>
</div>

  </div><!--  container -->
  </body>
  </html>

Answer №1

The correct method for accomplishing this task is as follows:

<td style="min-width: 500px;">1</td>

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

Preventing mouse clicks on checkboxes and triggering events using JavaScript - a complete guide

We have a Table grid with multiple columns, one of which is a Select Box (CheckBox). The expected behavior is that when a row is clicked, the respective CheckBox should get checked, and clicking on the CheckBox itself should update it. I tried implementin ...

single calendar bootstrap-datepicker allowing users to select date ranges

Is it possible to create a single calendar range date picker with Bootstrap instead of using two separate calendars? Currently, I have implemented a solution with two calendars. $('#datepicker').datepicker({ }); <link href="https://cdnjs.cl ...

Adding numerous rows to a database by iterating through a while loop

Greetings! I am currently facing an issue with storing values in my database. The program's logic involves the user inputting the number of subjects they will take. For instance, if a user inputs 6 subjects, 6 input fields with text values should be g ...

Creating a dropdown menu in AngularJS using the ng-repeat directive

I have recently started working with AngularJS. I am trying to create three tickets using ng-repeat, each containing a dropdown list to select the number of tickets. However, I am facing an issue where the selected number is not displaying in the span. Can ...

I am experiencing issues with CSS functionality in my Ruby on Rails application

Currently, I am in the process of creating a blog based on Mackenzie Child's 12 in 12 RoR tutorials. I diligently followed all the steps in the tutorial and adhered strictly to his code. However, I encountered an issue with the CSS stylesheets not be ...

Transform Arabic numerals into Roman numerals using only CSS styling

Currently developing a custom theme for a website and faced with the restriction of not being able to use Javascript. My goal is to translate certain numbers into Roman numerals. I attempted the following: .score:before { counter-reset: mycounter att ...

Ways to position Drop-down menu flush against the left edge of the webpage?

I am facing a challenge in customizing my CSS3 Mega drop-down menu. I want the mega menu to start from the left side of the main page, beginning from the home button area and extending all the way to the end. Currently, it is appearing where the parent men ...

Error: The function 'document.getsElementsByClassName()' is not defined when evaluating 'undefined'

Actual Error TypeError: undefined is not a function (evaluating 'ActiveElem[i].hasClass('active'); HTML <div class = 'Carousel-Inner'> <div class="morningSlide active"> <img src="/Users/KO527/Sites/TarasDeli ...

Double f span causing unusual behavior in Chrome browser

Why does the highlight focus on "ort" instead of "fort"? It appears this occurs when there are two f's. When I substitute f with other letters, like d, it shows correctly. Could this be a bug in Chrome? Chrome version is chrome83. add: It seems to be ...

Tips for dynamically loading a modal

Hello, I am curious about dynamically loading modals on different images within my current webpage. https://i.sstatic.net/yhTgs.png For example, when the life of Pi image is clicked, a modal pops up displaying relevant information. https://i.sstatic.net ...

Manually browse through images in photoswipe by clicking on them to move to the previous or next ones

Utilizing photoswipe within my mobile app has been a seamless experience. Instead of utilizing the full screen view, we are displaying images within a target div. A new requirement was introduced to hide the built-in toolbar and incorporate arrow buttons ...

Facing Challenges with Python Selenium while Accessing Specific Form Elements in Salesforce

Recently, I've been using Selenium to automate some data entry tasks on Salesforce. So far, my script successfully loads the webpage, allows me to log in, and clicks an "edit" button. Now, I'm encountering an issue when trying to input data into ...

Why is my data not being saved to the database when using eloquent?

I am encountering an issue with my form submission. Although the data is present when using dd() on Requests, the save() function does not work as expected, resulting in the data not being stored in the table. I am attempting to add new Users via a backoff ...

Responsive Design: Concealing a Sidebar with CSS

Seeking assistance with optimizing the layout of my app, . It currently displays a menu on the left and a login form in the center, with a graph shown to users upon logging in. Is there a way to configure it so that when accessed on iOS: 1) the left menu ...

Having trouble getting the Bootstrap toggle checkbox to function properly within Angular 2 components?

Working on an Angular 2 project with Bootstrap, I recently tried to integrate a bootstrap-toggle checkbox into the UI. Despite following the instructions from this site, the checkbox was displayed as a normal checkbox instead of toggled. The Index.html cod ...

Learning to activate music on a webpage using the tab key in HTML

Is there a way to trigger the playback of an mp3 file when the tab key is pressed on a keyboard? I am designing a number system for a restaurant where entering a number and pressing tab will result in a noise being played to bring attention to the numbers ...

What is the best way to eliminate the final character in an input value once it has passed through regex validation in Angular8

Hello! I am attempting to remove the last digit of a string and update the input value each time my function checks if the input value passes a regex test on keypress. Initially, it works correctly, but then it adds an extra digit. After that, it works a ...

I continue to encounter a problem where GitHub refuses to navigate links, despite them being properly configured

While working on GitHub, I encountered an issue when trying to set up a website on GitHub domains - the links were not functioning properly. Here is an example of what I was dealing with: <!DOCTYPE html> <form action="homepage.html" meth ...

html nested table with merged columns

I've come across this issue before, but I just can't seem to figure out how to implement a multi-layered colspan in an HTML table. The HTML table I'm working with is from w3schools, but I want to create a colspan of 2 for Data 2 and Data 5. ...

The Issue of Missing HTML Registration Form Data in Django

My configurations in demo\urls.py, user\urls.py, views.py, and HTML form seem to be set up correctly. However, upon pressing the submit button on the HTML form, I encounter a "File Not Found" error. Even after seeking assistance from ChatGPT, fol ...