Search
 
SCRIPT & CODE EXAMPLE
 

HTML

CSS Setting Table Column Width

<table border="1" width="100%">
	<col style="width:40%">
	<col style="width:30%">
	<col style="width:30%">
	<thead>
	<tr>
		<th>Fruits</th>
		<th>Vitamin A</th>
		<th>Vitamin C</th>
	</tr>
	</thead>
	<tbody>
	<tr>
		<th>Apples</th>
		<td>98 ui</td>
		<td>8.4 mg</td>
	</tr>
	<tr>
		<th>Oranges</th>
		<td>295 ui</td>
		<td>69.7 mg</td>
	</tr>
	<tr>
		<th>Bananas</th>
		<td>76 ui</td>
		<td>10.3 mg</td>
	</tr>
	</tbody>
</table>
Comment

table column width

<!--Simple table with column width-->
<table>
    <colgroup>
       <col span="1" style="width: 15%;">
       <col span="1" style="width: 70%;">
       <col span="1" style="width: 15%;">
    </colgroup>
	<!--Put <thead> and <tr>'s here-->
    <tbody>
       <td>From</td>
       <td>Subject</td>
       <td>Date</td>
    </tbody>
</table>
<!--This code ensures that the columns span one column each (span attribute)-->
<!--Width attribute can be pixel too.-->
Comment

change table column width css

table {
  border: 1px solid black;
  table-layout: fixed;
  width: 200px;
}

th,
td {
  border: 1px solid black;
  width: 1000px;
  overflow: hidden;
}
Comment

change table column width css

<table>
  <tr>
    <th>header 1</th>
    <th>header 234567895678657</th>
  </tr>
  <tr>
    <td>data asdfasdfasdfasdfasdf</td>
    <td>data 2</td>
  </tr>
</table>
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Html :: registration form template bootstrap 
Html :: html table cell full width 
Html :: placeholder in html select 
Html :: svg img tag not showing 
Html :: how to change font color of h2 tag in html 
Html :: mat-tooltip on disabled button 
Html :: time input html 
Html :: whatsapp api 
Html :: range html 
Html :: html video player 
Html :: select2 html example 
Html :: tailwind nth child odd even 
Html :: class required bootstrap 3 
Html :: angular open pdf in new tab 
Html :: select option 
Html :: how to set canvas on background html 
Html :: html hyperlink 
Html :: html clickable image 
Html :: using svg icons in html 
Html :: relative vs absolute path html 
Html :: title tag in html 
Html :: how to defualt volume at 50% of video html 
Html :: when do i put my script in the body tags in html 
Html :: how to highlight text in html 
Html :: input email tag 
Html :: how to create a form 
Html :: how to add image in html from a folder 
Html :: remove reset all css using style property attribute in react component 
Html :: preformatted text html 
Html :: ConfirmPassword 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =