Can someone help me figure what selectors I need to change the width of my columns globally on my two column table?
Using this, will of course select all cells:
table td {
width: 50px;
}
What I want is this:
<table>
<tr>
<td style="width: 50px">data in first column</td>
<td style="width: 180px">data in second column</td>
</tr>
<tr>
<td style="width: 50px">more data in first column</td>
<td style="width: 180px">more data in second column</td>
</tr>
</table>
I'd like to put the width specification in a style sheet rather then typing the width implicitly for each tag. What CSS selector will let me set the 50px width and 180px appropriately?
The ::first-line selector is used to add a style to the first line of the specified selector. Note: The following properties can be used with ::first-line: font properties.
You start with -n, plus the positive number of elements you want to select. For example, li:nth-child(-n+2) will select the first 2 li elements.
It is possible to give several items on your page the same style even when they don't have the same class name. To do this you simply list all of the elements you want to style and put a comma between each one.
Simple selectors (select elements based on name, id, class) Combinator selectors (select elements based on a specific relationship between them) Pseudo-class selectors (select elements based on a certain state)
Yep.
td:first-child{
width:50px;
}
td:nth-child(2){
width: 180px;
}
or, as suggested by Brainslav's edit:
td:nth-child(1) {
width: 50px;}
td:nth-child(2) {
width: 180px;}
link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With