Bootstrap5 Typography
Bootstrap 5 Default Settings
Bootstrap 5's default font-size is 16px, and line-height is 1.5.
The default font-family is "Helvetica Neue", Helvetica, Arial, sans-serif.
In addition, all
elements have margin-top: 0 and margin-bottom: 1rem (16px).
-
Bootstrap defines styles for all HTML headings (h1 to h6). See the example below:
Example
<div class="container">
<h1>h1 Bootstrap heading
h1
<
h2
h2 Bootstrap heading
h2
<
h3
h3 Bootstrap heading
h3
<
h4
h4 Bootstrap heading
h4
<
h5
h5 Bootstrap heading
h5
<
h6
h6 Bootstrap heading
h6
div
Try it »
You can also use the .h1 to .h6 classes to set the style of elements:
Example
<div class="container">
<p class="h1">h1 Bootstrap heading
p
<p class="h2">h2 Bootstrap heading
p
<p class="h3">h3 Bootstrap heading
p
<p class="h4">h4 Bootstrap heading
p
<p class="h5">h5 Bootstrap heading
p
<p class="h6">h6 Bootstrap heading
p
div
Try it »
Display Heading Classes
Bootstrap also provides four Display classes to control heading styles: .display-1, .display-2, .display-3, .display-4.
Example
<div class="container">
<h1>Display Heading
h1
<
p
Display headings can output a larger, bolder font style.
p
<h1 class="display-1">Display 1
h1
<h1 class="display-2">Display 2
h1
<h1 class="display-3">Display 3
h1
<h1 class="display-4">Display 4
h1
div
Try it »
In Bootstrap 5, HTML element is used to create smaller, lighter-colored text:
Example
<div class="container">
<h1>Smaller Text Heading
h1
<
p
The small element is used for smaller, lighter-colored text:
p
<
h1
h1 heading
<
small
Subtitle
small
h1
<
h2h2 heading
<
small
Subtitle
small
h2
<
h3h3 heading
<
small
Subtitle
small
h3
<
h4h4 heading
<
small
Subtitle
small
h4
<
h5h5 heading
<
small
Subtitle
small
h5
<
h6h6 heading
<
small
Subtitle
small
h6
divTry it »
Bootstrap 5 defines tags and the .mark class with a yellow background and some padding:
Example
<div class="container">
<h1>Highlighted Text
h1
<
p
Use the mark element to
<
mark
Highlight
marktext.
p
div
Try it »
Bootstrap 5 defines HTML element's style as a dashed border displayed at the bottom of the text:
Example
<div class="container">
<h1 Abbreviations h1>
<p>The abbr element is used to mark up an abbreviation or acronym:
p
<p The>
<abbr title=">World Health Organization
"
WHO
abbr
was founded in 1948.
p
div
Try it »
For quoted content, you can add the
.blockquote class on the :Example
<div class="container"> <h1 Blockquotes h1> <p>The blockquote element is used to present content from another source:
p
< blockquote class = " blockquote " < pFor 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.
p
< footer class = " blockquote-footer "From WWF's website
footer
blockquote
div
Try it »
Bootstrap 5 defines HTML
The element's style is as follows:
Example
<div class="container"> <h1>Description Lists
h1
<
p
The dl element indicates a description list:
p
< dl < dt Coffee dt < dd dd < dt Milk dt < dd dd dl divTry it »
Bootstrap 5 定义 HTML
元素的样式如下:实例
<div class="container"> <h1 代码片段 h1> <p>可以将一些代码元素放到 code 元素里面:
p
<
p
以下 HTML 元素:
< code span code , < code section code, 和
< code div code用于定义部分文档内容。
p
div
尝试一下 »
Bootstrap 5 定义 HTML 元素的样式如下:
实例
<div class="container"> <h1>Keyboard Inputs
h1
<
p
To indicate input that is typically entered via the keyboard, use the kbd element:
p
< p Use < kbdctrl + p
kbd
to open the Print dialog box.
p
div
尝试一下 »
Bootstrap 5 定义 HTML
元素的样式如下:实例
<div class="container"> <h1>Multiple Code Lines
h1
<
p
For multiple lines of code, use the pre element:
p
<
pre
Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and line breaks.
pre
div
尝试一下 »
更多排版类
下表提供了 Bootstrap5 更多排版类的实例:
类名 描述 实例 .lead 让段落更突出 尝试一下 .small 指定更小文本 (为父元素的 85% ) 尝试一下 .text-start 左对齐 尝试一下 .text-center 居中 尝试一下 .text-end 右对齐 尝试一下 .text-justify 设定文本对齐,段落中超出屏幕部分文字自动换行 尝试一下 .text-nowrap 段落中超出屏幕部分不换行 尝试一下 .text-lowercase 设定文本小写 尝试一下 .text-uppercase 设定文本大写 尝试一下 .text-capitalize 设定单词首字母大写 尝试一下 .initialism 显示在 元素中的文本以小号字体展示,且可以将小写字母转换为大写字母 尝试一下 .list-unstyled 移除默认的列表样式,列表项中左对齐 ( 和
中)。 这个类仅适用于直接子列表项 (如果需要移除嵌套的列表项,你需要在嵌套的列表中使用该样式)
尝试一下 .list-inline 将所有列表项放置同一行 尝试一下