Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello Guys,

Let's say that i have a table with 5 column's in a single row, i would like to know how to access the specific td in css to set it's width? Like for example for the 1st td width = "10px", 2nd td width = "15px" and so on. How am i supposed to do this in css? Thanks guys.


Posted
Updated 6-Jul-12 7:29am
v3

1 solution

define id to each td in your html say

CSS
<style type="text/css">
#tdfirst
{
width:50px;
}

#tdsecond
{
width:50px;
}

</style>


HTML
<table><tr><td id="tdfirst"></td><td id="tdsecond"></td></tr></table>



mark it solution if it is your answer

Thanks
 
Share this answer
 
Comments
Michael Sernal 6-Jul-12 14:13pm    
What if you have multiple rows? do other td's follow to the ones you put the id to? because i already have classes and my table contains multiple rows, thanks.
Sergey Alexandrovich Kryukov 6-Jul-12 14:20pm    
Each td style will define minimal width for its column, so the rendering will chose the actual width to fit any of the tds, also taking into account its content. It's easier to try to see how it works.
--SA
AshishChaudha 7-Jul-12 1:08am    
Then use '.' inplace of '#' sign in CSS and in TD use class="tdfirst" and so on. Then you can use it in multiple rows.

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900