You are here: Re: Can you format table contents from an outer DIV tag? « HTML « IT news, forums, messages
Re: Can you format table contents from an outer DIV tag?

Posted by Andy Dingley on 10/13/06 13:46

bradsalmon wrote:

> Basically because of issues out of my control I have to try and style
> the contents of a table from an outer DIV tag.

You style things with CSS, not with HTML (any tags). To apply the CSS
you need some way of identifying where it should be applied, known as a
"selector". You _might_ be able to set some properties from the <div>,
but only if the stylesheet applied to the table is already inheriting
them (and for lots of them it won't be).

Now assuming your problem is like that of a server-side include where
there's some boilerplate in the <table> that you can't modify, but you
can modify the page outside this, then this is easy in CSS.

Add a CSS stylesheet to the <head> of the HTML page

<style type="text/css" >
div.foo table td {
margin-left: 3pt;
font-size: 10pt;
}
</style>

Then wrap your table up like this

<div class="foo" >
<table>
[...]
</table>
</div>


Adjust the actual CSS to taste.

If you can address the table itself (maybe add an class attribute to it
itself, or if you can guarantee that it's the only table on the page)
then you might be able to skip the <div> and simplify the selector.

If you don't have access to the <head>, then you can try plcing the
<style> element in the <body> of the HTML. It's not valid, but it does
usually work and can sometimes get you out of a hole.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация