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

css table fixed column width

table {
	table-layout: fixed;
}

td {
	overflow: hidden;
    width: 100px;
}
Comment

set 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 :: html dash code 
Html :: html how to add an image 
Html :: branch icon font awesome 
Html :: tailwind display inline block 
Html :: laser full form 
Html :: Hoow to open a css property in css 
Html :: upload only img 
Html :: move table tfoot at top 
Html :: twig keys 
Html :: how to create html dropdown 
Html :: show timestamp as yyyy mm dd html angular 
Html :: form with no action 
Html :: how to make a distance between a label and input html 
Html :: meta name viewport 
Html :: how to make an image a full background in html 
Html :: html link favicon 
Html :: ion-select cancel text 
Html :: how to stop text in html from becoming a link 
Html :: how to make a scrollable list in html 
Html :: change icon on button click 
Html :: upload svg to wordpress 
Html :: do you like grepper 
Html :: bootstrap 5 toggle switch 
Html :: bullet list html mdn 
Html :: csrf token html form 
Html :: redirect to folder html 
Html :: Html.ActionLink with parameters 
Html :: fa facebook icon 
Html :: bootstrap 4 
Html :: how to add a favicon to html 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =