0

I create a CSS for a p tag. I don't know why font:bold and font-size=15 doesn't work. It means : font in this class doesn't bold and doesn't change size although I change number of font-size property. But some other attributes work well, for example : color or text-decoration

Here is short piece of my HTML5 page :

1) CSS Page

<style>
    .title{
        font: bold;
        font-size: 15;
        color: red;
        text-decoration: underline ;
    }
</style> 

2) HTML Page:

<div class="question">
     <p class="title">
         Here is my title
     </p>
</div>

Please help me.

Thanks :)

4

2 回答 2

3

It's font-weight and you need to specify a unit for size. Try:

font-weight: bold;
font-size: 15px;

jsFiddle example


Font Size:

xx-small, x-small, small, medium, large, x-large, xx-large

A set of absolute size keywords based on the user's default font size (which is medium). Similar to presentational HTML's through where the user's default font size is .

larger, smaller

Larger or smaller than the parent element's font size, by roughly the ratio used to separate the absolute size keywords above.

length

A positive length. When the units are specified in em or ex, the size is defined relative to the size of the font on the parent element of the element in question. For example, 0.5em is half the font size of the parent of the current element.

percentage

A positive percentage of the parent element's font size. It is best to avoid using values that are not relative to the user's default font size, such as lengths with units other than em or ex. However, if such values must be used, px are preferred over other units because their meaning does not vary depending on what the operating system thinks (generally incorrectly) the resolution of the monitor is.

Font Weight:

normal

Normal font weight. Same as 400.

bold

Bold font weight. Same as 700.

lighter

One font weight lighter than the parent element (among the available weights of the font).

bolder

One font weight darker than the parent element (among the available weights of the font).

100, 200, 300, 400, 500, 600, 700, 800, 900

Numeric font weights for fonts that provide more than just normal and bold. If the exact weight given is unavailable, then 600-900 use the closest available darker weight (or, if there is none, the closest available lighter weight), and 100-500 use the closest available lighter weight (or, if there is none, the closest available darker weight). This means that for fonts that provide only normal and bold, 100-500 are normal, and 600-900 are bold.

Source: https://developer.mozilla.org/en/CSS/font-size and https://developer.mozilla.org/en/CSS/font-weight

于 2012-07-04T19:11:29.367 回答
1

The property you are looking for is font-weight and you text size must have a unit (em, px, pt):

font-weight: bold;
text-size: 1.2em; /* em is the preferred unit */
于 2012-07-04T19:12:08.697 回答