Jump to content


Photo

Force CSS Class


  • Please log in to reply
6 replies to this topic

#1 Lang

Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 08 November 2006 - 07:55 PM

I have a table cell with a class - is it possible to make this class force itself over any other formatting in the table cell?

Example:

<table>
  <tr>
   <td class="cell">
	  <div style="font-size:10px;">This is some text</div>
   </td>
  </tr>
</table>

Is possible to force the class of the cell so that the div does not affect the formatting?

Thanks,

#2 greg

greg

    Jedi In Training

  • Members
  • PipPip
  • 499 posts
  • Location:New York City
  • Interests:Fine art, web and graphic design, naval architecture, chess, and sports.

Posted 08 November 2006 - 08:04 PM

I'm not sure if I'm understanding your question 100%.

The way CSS works is anything lower in the stylesheet rules over anything above it.

For example:

#table {
 background: #000;
}

#table td {
 background: #fff;
}

The second rule (with the white background color) will override the first one, because it is below it in the stylesheet.

#3 Lang

Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 08 November 2006 - 08:20 PM

Yes I know that - but there is a <div> tag that will be overriding the class given in the cell. Is it possible to ignore the style property in the <div> tag with a CSS class is what i'm asking.

#4 greg

greg

    Jedi In Training

  • Members
  • PipPip
  • 499 posts
  • Location:New York City
  • Interests:Fine art, web and graphic design, naval architecture, chess, and sports.

Posted 09 November 2006 - 05:11 AM

I might be misunderstanding you, but the answer I gave before is still the answer.

If you put the div's styling below the cell's styling, then it won't apply to the cell. If you put the cell's styling below the div's styling, it will inherit automatically, so you'll have to override it by changing the style.

#5 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 09 November 2006 - 05:16 PM

Order of style inheritance is like this:
Included CSS
Embedded CSS
In-line CSS

The bottom most takes precidence over the top. So, if you're going to use in-line styling, and try to over ride it with a class, you won't get very far.

#6 jamie0607

jamie0607

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 21 October 2010 - 07:00 AM

Hi,

Try looking up the !important tag to be included in the class.

This overules the precedence set in the inheritance throughout the document, and will force those rules.

font-size: 20px; !important

#7 _*aprillove20_*

_*aprillove20_*
  • Guests

Posted 03 November 2010 - 12:09 PM

Thanks greg for the ideas regarding the CSS.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users