• 0

CSS td width


Question

Originally my table had two columns and each <td> had its width set to 50%. I tried making td.w50 in my style sheet with a width:50%; attribute and putting it in my table class declaration but none of my cells were given the correct width.

I'm basically wanting to make all cell widths 50% without having to have width="50%" everywhere. Help this CSS newb.

CSS Example:

td.w50
{
	width:50%;
}

Table Example:

&lt;div class="pad15 MainBody"&gt;
  &lt;table class="w50" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%"&gt;
          &lt;tr class="TableTitle filledtitle"&gt;
            &lt;td&gt; Students&lt;/td&gt;
            &lt;td&gt;Last Updated&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt; Meredith&lt;/td&gt;
            &lt;td class="center"&gt;05-05-2004&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="filledlist"&gt;
            &lt;td&gt; Kyle&lt;/td&gt;
            &lt;td class="center"&gt;05-02-2004&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt; Katharine&lt;/td&gt;
            &lt;td class="center"&gt;05-04-2004&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="filledlist"&gt;
            &lt;td&gt; Liz&lt;/td&gt;
            &lt;td class="center"&gt;05-05-2004&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
  &lt;/div&gt;

Link to comment
https://www.neowin.net/forum/topic/234935-css-td-width/
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Are you using the list to layout your page? Or are you using it to display information?

If it's for a layout, don't use tables.

Plus, you need to stop using any attribute tags, except for class and id. That's what CSS is for.

Link to comment
https://www.neowin.net/forum/topic/234935-css-td-width/#findComment-584795680
Share on other sites

  • 0
  fubarshibby said:
Are you using the list to layout your page? Or are you using it to display information?

If it's for a layout, don't use tables.

Plus, you need to stop using any attribute tags, except for class and id. That's what CSS is for.

584795680[/snapback]

And cellspacing. CSS doesn't support that does it? :p

Link to comment
https://www.neowin.net/forum/topic/234935-css-td-width/#findComment-584796361
Share on other sites

  • 0

I'm using the table to display data, a list of students and their last update date. I know I'm not supposed to use attributes but right now I'm just trying to figure this one part out and then I'll move on to other stuff.

Any ideas as to what to do?

Link to comment
https://www.neowin.net/forum/topic/234935-css-td-width/#findComment-584796991
Share on other sites

  • 0

td.w50 will only apply to td tags with a class name of 'w50', not to any td tags inside a table with that class name. Since you're using <table class="w50"> and you have no table.w50 defined, nothing will happen.

You need to either -

1. Give each td tag inside the table a class name of 'w50' (i.e. <td class="w50">).

2. A better method. Use:

table.w50 td {
width: 50%;
}

That will apply to all td tags inside a table tag whose class name is 'w50'.

Link to comment
https://www.neowin.net/forum/topic/234935-css-td-width/#findComment-584797112
Share on other sites

  • 0
  djtaylor said:
2. A better method. Use:

table.w50 td {
width: 50%;
}

That will apply to all td tags inside a table tag whose class name is 'w50'.

584797112[/snapback]

Yes! that's what I was trying to do. I thought I wasn't doing it right. Thank you :)

Link to comment
https://www.neowin.net/forum/topic/234935-css-td-width/#findComment-584797579
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • - What's your salary? Is it more than $100k a year? - Nah, it's $100 mil a year.
    • Compared to my ear buds which are the size of a matchbox, cover a much broader frequency range, and work everywhere without setup? Yeah, still not buying this as a replacement.
    • Meta's Superintelligence team staffed by 50% Chinese talent, 40% ex-OpenAI by Hamid Ganji Mark Zuckerberg's latest big bet at Meta involves building a team of the best AI superstars in the market to lead the so-called Superintelligence Labs. The goal of this team is to develop AI models that will ultimately lead to Artificial General Intelligence (AGI). AGI refers to an AI model with capabilities comparable to, or even beyond, those of the human brain. Achieving human-level cognitive abilities with an AI model requires substantial investments, as well as hiring the best talent to build such a system. That's why Meta is throwing hundreds of millions of dollars at AI researchers from OpenAI, Apple, and other companies to recruit them for its Superintelligence team. A user on X has now shared a spreadsheet that provides us with some unique insights into Meta's Superintelligence team and the origins of its 44 employees. The leaker claims this information comes from an anonymous Meta employee. The listing claims that 50 percent of the staff at the Superintelligence team are from China, which demonstrates the significant role of Chinese or Chinese-origin researchers in Met's AI efforts. Additionally, 75 percent of these staff hold PhDs, and 70 percent of them work as researchers. Interestingly, 40 percent of the staff are ex-OpenAI employees whom Mark Zuckerberg poached from the maker of ChatGPT. Additionally, 20 percent of Meta's Superintelligence team members come from Google DeepMind, and another 15 percent come from Scale AI, a startup that Meta recently acquired in a $15 billion deal. Another interesting point is that 75 percent of the Superintelligence team are first-generation immigrants. The leaker claims that each of these employees is now earning between $10 million and $100 million per year, although Meta still needs to confirm these substantial figures. However, it has already been reported that Meta is offering up to $100 million in signup bonuses to poach the best AI talent from OpenAI and other rivals. The revelation that half of Meta's Superintelligence team consists of Chinese nationals could trigger concerns within the Trump administration and Congress.
    • From a quick Google it seems 6GHz is optional on 802.11be. Ubiquiti has one, Unifi U7 Lite.
    • Disagreed, I feel it’s going somewhere and his role served a purpose - and moreover with maybe what 10 mins of screen time - he had a bit of character development also.
  • Recent Achievements

    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
    • One Month Later
      Ian_ earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      ATLien_0
      207
    3. 3
      Michael Scrip
      206
    4. 4
      Xenon
      139
    5. 5
      +FloatingFatMan
      114
  • Tell a friend

    Love Neowin? Tell a friend!