font-size

font-size

The font-size attribute refers to the size of the font from baseline to baseline when multiple lines of text are set solid in a multiline layout environment. For SVG, if a <length> is provided without a unit identifier (e.g., an unqualified number such as 128), the browser processes the <length> as a height value in the current user coordinate system.

If a <length> is provided with one of the unit identifiers (e.g., 12pt or 10%), then the browser converts the <length> into a corresponding value in the current user coordinate system

As a presentation attribute, it also can be used as a property directly inside a CSS stylesheet, see css font-size for further information.

Usage context

Categories Presentation attribute
Value <absolute-size> | <relative-size> | <length> | <percentage> | inherit
Initial value medium
Animatable Yes
Normative document SVG 1.1 (2nd Edition)

Example

font size with pixel

css

h1 {font-size:30px;}
h2 {font-size:20px;}
p {font-size:15px;}

html

<h1>30pixel</h1>
<h2>20pixel</h2>
<p>15pixel</p>

font size with Em

css

h1 {font-size:2.9em;}
h2 {font-size:1.9em;}
p {font-size:0.9em;} 

html

<h1>2.9em</h1>
<h2>1.9em</h2>
<p>0.9em</p>

Elements

The following elements can use the font-size attribute

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-size

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部