PepeHands
PepeHands

Reputation: 1406

Font size in html using css

in my project I need to right some big text, so in my css file I wrote:

#wrong_answer
{
    color: red;
    font-size: 30;
    font-weight: bold;
}

and in my js file:

function wrong_answer()
{    
    $("body").append("<p id='wrong_answer'>Is not correct</p>");
};

and finaly I got red text, but very-very small and if I change font-size the size of text doesnt changes.

so question is why cant I change font-size?

Upvotes: 0

Views: 174

Answers (5)

Jasper
Jasper

Reputation: 76003

30 what? 30px, 30pt, 30%, 30em? You have an invalid property value there.

When using jQuery you can specify just an integer but that's because jQuery treats integers like pixel values, e.g.:

//this will work
$([selection]).css({ fontSize : 30 });

Here are some great docs for font-size: https://developer.mozilla.org/en-US/docs/Web/CSS/font-size

UPDATE

You can use your developer tools (Chrome/Firefox/Safari for sure) to inspect the CSS associated with an element. When an invalid property value is encountered, these developer tools will alert you to the fact.

Upvotes: 7

rahulbehl
rahulbehl

Reputation: 2709

Read this page for better understanding about fonts. http://www.w3schools.com/css/css_font.asp

Upvotes: 2

neuquen
neuquen

Reputation: 4169

Should be font-size: 30px or something similar. You need to specify the unit type.

Upvotes: 1

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201588

The CSS declaration font-size: 30 is invalid and ignored by conforming browsers. If you mean pixels, you need to say that:

font-size: 30px

Upvotes: 2

talemyn
talemyn

Reputation: 7950

You need to specify the "unit of size" . . .

font-size: 30px;

Upvotes: 3

Related Questions