/    Sign up×
Community /Pin to ProfileBookmark

JS to change CSS font size

What would the JS commands be to change the child element font size
of a class setting based upon the size of the parent element font?

In the past the tag would be <font size=-1>, but the tag is now deprecated.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meOct 21.2009 — fontSize. (font-size)

a value of 75&#37; should display at 75% of the settings inherited from the parent, or more precisely, already (via class, tag, etc).

a value of 12pt is, well, 12pt anywhere.

absent any other compelling selectors in play, parentNode.fontSize="75%"; should do what you want.

if you do have lots of selectors going around, you'll need to grab the appliedStyle then loop through kids applying a modification of that detected value.

let me know if you want a good xbrowser applied style code. Most of them stink; a lot of them ask "are you IE?" every single time they fire...
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...