Mr.Chowdary Mr.Chowdary - 12 days ago 5
CSS Question

bgcolor to the th of table with width 70% possible in a table

I want to give bgcolor to the th attribute only with width 70%.

Header is like "Mega Event Offer". I want to give background color to that only. But it's width is big. SO it is exceeding the heading also.. Can we do it? I googled.. But no use..

Any idea?

Answer

Not sure I fully understand the problem here, but given that you want to apply the background only behind the text and not on the entire th-element, I guess you could wrap the text in a span-element and apply the background-color to that instead of the entire th-element.

Something like this:

Markup

..
  <th>
     <span class="mega-event">Mega Event Offer</span>
  </th>
..

CSS

.mega-event {
   background-color: #888;
}