By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,302 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,302 IT Pros & Developers. It's quick & easy.

Can I modify body, table, and p attributes with a style?

P: n/a
Hello all,

Me again :>) Can I modify certain attributes in a style within a
stylesheet? Example: I have a style sheet that looks like this:

body { background-color: black; font-family: Arial; font-size: 13pt;
color: white; margin: 5 5 5 5 }

p { font-family: Arial; font-size: 13pt; color: white; line-height:
125%; margin-top: 5px; margin-bottom: 5px}

table {width: 100%; align:top; border-collapse: collapse; padding: 5px}

tr { vertical-align: top; text-align: left}

td { font-family: arial; font-size: 13pt; color: white; line-height:
125%; padding: 7px }

#tdfaq { font-family: arial; font-size: 13pt; font-weight: bold; color:
black; line-height: 125%; padding: 7px }
Now, say I want to create a style within the sheet but I want the
tables and font to look different. Could I do that with a command
similar to this:?

..newstyle {body: XXXX; table: XXXX; td:XXXX; p:font-color=XXXX}

I'm sure that this command is invalid, but I think y'all get the idea.
The thing is, I want to create ONE master style sheet for the entire
site, but some pages will have different fonts or font colors and the
tales will look different as well.

Also one problem I'm having is that if I have a <P> tag within a <TD>
tag, the font color defaults to whatever the <P> tag is. In the example
above, you can see that I have a <TD> called "#tdfaq". You can see that
the font color within that <TD> is black. But when a <P> tag is used
within that, the font comes out white. I'd like to avoid this by doing
what I explained above: creating a style (within a stylesheet) that has
different <P> or <TD> tags.

Does this make sense or did I confuse everyone? Thanks for any answers.

Viken K.

Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Els
Viken Karaguesian wrote:
Me again :>) Can I modify certain attributes in a style within a
stylesheet? Example: I have a style sheet that looks like this:

body { background-color: black; font-family: Arial; font-size: 13pt;
color: white; margin: 5 5 5 5 }
Don't use pt for font-sizes on screen. Use % instead, 100% being the
medium size on the visitor's browser.
Now, say I want to create a style within the sheet but I want the
tables and font to look different. Could I do that with a command
similar to this:?

.newstyle {body: XXXX; table: XXXX; td:XXXX; p:font-color=XXXX}

I'm sure that this command is invalid, but I think y'all get the idea.
The thing is, I want to create ONE master style sheet for the entire
site, but some pages will have different fonts or font colors and the
tales will look different as well.
No problem, if the page is entirely different, make a separate
stylesheet. If only a few things are different, give those pages
different classes where they are different, and use those classes in
the stylesheet.
Also one problem I'm having is that if I have a <P> tag within a <TD>
tag, the font color defaults to whatever the <P> tag is.
Of course :-)
In the example
above, you can see that I have a <TD> called "#tdfaq". You can see that
the font color within that <TD> is black. But when a <P> tag is used
within that, the font comes out white. I'd like to avoid this by doing
what I explained above: creating a style (within a stylesheet) that has
different <P> or <TD> tags.
You could just have it like this in your stylesheet:

p{color:white;background:black;}
td{color:black;background:white;}
td p{color:black;background:white;}

"td p" means any <p> element which is inside a <td> element.
Does this make sense or did I confuse everyone? Thanks for any answers.


I'm not confused ;-)

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -
Jul 21 '05 #2

P: n/a
Viken Karaguesian wrote:
Hello all,

Me again :>) Can I modify certain attributes in a style within a
stylesheet? Example: I have a style sheet that looks like this:

body { background-color: black; font-family: Arial; font-size: 13pt;
color: white; margin: 5 5 5 5 }
5 what? pixels? ems? light-years? With HTML pixels are assumed; with
CSS you must specify the units unless the value is 0.
table {width: 100%; align:top; border-collapse: collapse; padding: 5px}
No such property as align in CSS, Perhaps you mean vertical-align. But
you want to set this property for td, not table.
td { font-family: arial; font-size: 13pt; color: white; line-height:
125%; padding: 7px }
You should specify alternatives for the font in case Arial is not
installed. E.g. font-family:Arial, Helvetica, sans-serif;
#tdfaq { font-family: arial; font-size: 13pt; font-weight: bold; color:
black; line-height: 125%; padding: 7px }
Ditto
Now, say I want to create a style within the sheet but I want the
tables and font to look different. Could I do that with a command
similar to this:?

.newstyle {body: XXXX; table: XXXX; td:XXXX; p:font-color=XXXX}
No
I'm sure that this command is invalid, but I think y'all get the idea.
The thing is, I want to create ONE master style sheet for the entire
site, but some pages will have different fonts or font colors and the
tales will look different as well.
This is easy, but you have to learn CSS. I suggest you buy a good
reference book.
Also one problem I'm having is that if I have a <P> tag within a <TD>
tag, the font color defaults to whatever the <P> tag is. In the example
above, you can see that I have a <TD> called "#tdfaq". You can see that
the font color within that <TD> is black. But when a <P> tag is used
within that, the font comes out white.
Which is what is supposed to happen.
I'd like to avoid this by doing
what I explained above: creating a style (within a stylesheet) that has
different <P> or <TD> tags.


Again, get a good CSS reference book. See
http://www.upsdell.com/BrowserNews/res_css.htm

Jul 21 '05 #3

P: n/a
Viken Karaguesian wrote:
Now, say I want to create a style within the sheet but I want the
tables and font to look different. Could I do that with a command
similar to this:?

.newstyle {body: XXXX; table: XXXX; td:XXXX; p:font-color=XXXX}
I'm really not sure what you are trying to achieve here, but see:

http://www.w3.org/TR/CSS2/selector.html

I think you might want a descendant selector.
Also one problem I'm having is that if I have a <P> tag within a <TD>


While it is possible to have tabular data consisting of paragraphs, it isn't
very common. You should check to make sure the semantics of your markup are
appropriate.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.