Blynn
Blynn

Reputation: 1411

Is it possible to add bold and Italic in one line is css?

Currently I saw you can do something like:

body{
font-weight:bold;
font-style:italic;
}

Is there a way to do...

body{
font: bold italic???
}

Upvotes: 0

Views: 2198

Answers (2)

Stefan
Stefan

Reputation: 114148

Yes, it is, just like you said, using font:

p { font: bold italic large Palatino, serif }

From the docs:

The font property is, except as described below, a shorthand property for setting font-style, font-variant, font-weight, font-size, line-height and font-family at the same place in the style sheet.

Upvotes: 0

j08691
j08691

Reputation: 207891

Yes, via the CSS shorthand font rule.

Formal syntax: [ [ <‘font-style’> || || <‘font-weight’> || <‘font-stretch’> ]? <‘font-size’> [ / <‘line-height’> ]? <‘font-family’> ] | caption | icon | menu | message-box | small-caption | status-bar

See also: http://www.w3.org/TR/CSS2/fonts.html#font-shorthand

Some examples:

p { font: 12px/14px sans-serif }
p { font: 80% sans-serif }
p { font: x-large/110% "New Century Schoolbook", serif }
p { font: bold italic large Palatino, serif }
p { font: normal small-caps 120%/120% fantasy }

Upvotes: 5

Related Questions