Joshua Terrill
Joshua Terrill

Reputation: 2017

If an element doesn't have a font-size, give it one

I am trying to create something in jquery that will add a default font-size to every element on the page if it doesn't already have one.

How would I do that?

Upvotes: 0

Views: 52

Answers (3)

David Passmore
David Passmore

Reputation: 1

Read up on CSS Resets. With a little research you'll see how to set a default font size that can be flexibly overridden in ways that you can easily control. You'll prefer to do this in CSS, and perhaps use JS to make unique localized modifications, if anything. Most of your style markup can and should be in CSS.

Upvotes: 0

AmmarCSE
AmmarCSE

Reputation: 30607

No need for jQuery. Just use the css universal selector like

*{
    font-size: 12px;
}

Upvotes: 1

Sean Stopnik
Sean Stopnik

Reputation: 1868

Use CSS for this.

body {
    font-size: 14px; /* Or whatever size you want */
}

Upvotes: 0

Related Questions