Different Font Styles on the Same Page (Full Version)

All Forums >> [Web Development] >> Cascading Style Sheets



Message


Bruce2000 -> Different Font Styles on the Same Page (1/14/2007 14:42:46)

Lets say I have some text in one cell that is going to be over a dark background so I'd like to make the font color white....but in another cell, I have a white background so I'd like to make the font a darker color. These colors will be the same on all pages so I'd like to use css. Is it better to create a seperate stylesheet for the white cell and the dark cell? Or can I specify in one stylesheet which cell to make white font?
I made a stylesheet for my page but it changes the font for the entire page. CSS seems a bit confusing.

Bruce




jaybee -> RE: Different Font Styles on the Same Page (1/14/2007 14:48:30)

there are several ways to do it but to get you started we can go with the simple one.

In the css file

.white {color:#fff;}
.black {color:#000;}
.red {color:#f00;}

In the code

If you want the entire section (div, table cell) whatever you're using:

<div class="white"> will apply to the whole div unless you apply a different color to a child of the div.

<td class="black"> Will make the contents of the cell black

If you just want a few words a different colour then

<p>I want to have <span class="red">these words red</span> but not these words.</p>
will result in

I want to have these words red but not these words.




Bruce2000 -> RE: Different Font Styles on the Same Page (1/15/2007 3:51:09)

Ok, here is what I am talking about. On my website pages:
My site

You see in my header bar, the navigation links. But that background is different than the body (white) so I can use a white font here but not in the body.

What I did was make a class identification for those links which are to be white and I placed before each of the links in the header bar like this:
<a class="header" href="..... >

Then in my style sheet I made this entry:
a.header:link {font-size: 12; font-weight: bold; color: #FFFAFA;}

Is that the correct way of doing it? Would I just create a new entry for visited and active like this: a.header:visited?

Also: you see the black vertical seperators between the links. In my site's online version I made each link fit neatly between the seperators by use of spaces. This can be done in css, right? I can remove all the extra spaces but I can't figure out how to increase the space between each word so they will fit into their spaces. Those seperators are not a font - they were built into the grey bar background. I should also mention that the links were placed in those spots simply with a <p> tag and margin & indent for the first word, "work", from its home position, in the top left corner of the cell. (the picture portion of my header is a cell) and the words that come after "work" are simply aligned with spaces. The only way I can think of doing it is by making some CSS commands for margin and indent, but then I would have to give each link word its own ID and each one wouldbe at a different indent value. This would mean that for each ID, I'd also have to copy all the CSS font tags. Unless I maybe create a <div> around all those links and apply the font declarations to all those links at once. I'm not sure if this is the right way to do this.




womble -> RE: Different Font Styles on the Same Page (1/15/2007 4:37:11)

You'll need to add either padding or margins to increase the space, e.g. a.header { padding-right: 10px; } (not sure how much you'll need - you'll need to play around with it until it looks right)




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875