Mr.Chowdary Mr.Chowdary - 9 months ago 48
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 Source

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:


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


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