site Search:


 
    All Forums Hot Topics Gallery






how-to block ads


 
Search Topic:
Uniqs:
382
Share Topic
Posting?
Post a:
Post a:
Links: ·How To Get Noticed ·Web Monks FAQ ·Webhosting FAQ ·Posting Code ·How To Post ·Webhosting forum
AuthorAll Replies


Sentinel
Premium
join:2001-02-07
Florida
kudos:1

CSS table link font size help please?

I'm guessing this will be an easy one for someone.

I am trying to make a page with a table in it and I want all the links on the page to be 12pt but I want the links in a table to be 8pt.

If, in my CSS I set the following:
<style>
A {font-size:12pt;}
BODY {font-size:8pt;}
TABLE {font-size:10pt;}
</style>
 
Then it doesn't work the way I want. So is there a way for me to define that all links on the page that are not in a table are a certain size but the links that are inside the table are a different size?


howardfine

join:2002-08-09
Saint Louis, MO
Reviews:
·AT&T Southwest
·Charter

4 edits

To target the links inside the table, do this:

table a { font-size: 10pt }
 

btw, pt is for print, not the web. pt is a unit of measurement equal to 1/72 inch. You never know what screen size the user has.


Sentinel
Premium
join:2001-02-07
Florida
kudos:1

Great! Thank you. I'll try that.

So what should I use if I want the font size to be a certain size?



howardfine

join:2002-08-09
Saint Louis, MO
Reviews:
·AT&T Southwest
·Charter

That's a subject of debate among some people and it sometimes depends on the context of the text. Most people use px which will set the size to the pixel level. But some prefer 'em' which will set the font relative to the current font size. Still others prefer percent '%' which will make it a percent of the size of the parent element.

This seems to be an article I see a lot of people seem to refer to but I might refer you to this one by the W3C themselves.



stray

join:2000-01-16
Warren, NJ

reply to Sentinel
A bit of refinement in the usage of font-size with %. The percent usage will make your selector's font size a percent of the size of the parent elements font-size, not a percentage of the actual parent element.

Here's a neat JQuery trick, if you want your font-size to be a percentage of the browser window height (or width.)


function winReshape() {
$('table a').css('fontSize', function() {
return ($(window).height() / 24) + "px"
});
}

$(document).ready(function(){
winReshape();
});

$(window).resize(function() {
winReshape();
});


In this example, the Javascript function winReshape() makes sure that the font-size (CSS) and fontSize (js) for 'table a' is always 1/24 of the browser window height. $(window).height() gives you the height of the browser window in pixels, which is then divided by 24 and applied to the CSS font-size of 'table a'.

winReshape() needs to be called when the document is first loaded, and subsequently whenever you resize the browser window.

--
V-Rtifacts - When Virtual Reality Was More Than Virtual



Sentinel
Premium
join:2001-02-07
Florida
kudos:1

reply to howardfine
Thank you.


Monday, 04-Jun 18:15:54 Terms of Use & Privacy | feedback | contact | Hosting by nac.net - DSL,Hosting & Co-lo
over 12.5 years online © 1999-2012 dslreports.com.
Most commented news this week
Hot Topics