Bootstrap Typography

Bootstrap uses Helvetica Neue, Helvetica, Arial, and sans-serif as its default font stack.

With Bootstrap's typography features, you can create headings, paragraphs, lists, and other inline elements.


Headings

Bootstrap defines styles for all HTML headings (h1 to h6). See the example below:

Example

<h1>I am heading 1 h1</h1> <h2>I am heading 2 h2</h2> <h3>I am heading 3 h3</h3> <h4>I am heading 4 h4</h4> <h5>I am heading 5 h5</h5> <h6>I am heading 6 h6</h6>

Try it yourself »

The result is as follows:

标题

Inline Subheadings

If you want to add an inline subheading to any heading, simply add <small> alongside the element, or add.smallclass, so that you get a text with smaller font size and lighter color, as shown in the example below:

Example

<h1>I am heading 1 h1.<small>I am subtitle 1 h1</small></h1> <h2>I am heading 2 h2.<small>I am subtitle 2 h2</small></h2> <h3>I am heading 3 h3.<small>I am subtitle 3 h3</small></h3> <h4>I am heading 4 h4.<small>I am subtitle 4 h4</small></h4> <h5>I am heading 5 h5.<small>I am subtitle 5 h5</small></h5> <h6>I am heading 6 h6.<small>I am subtitle 6 h6</small></h6>

Try it yourself »

The result is as follows:

内联子标题

Lead Body Copy

To add emphasized text to a paragraph, you can add class="lead", which will result in larger, bolder text with a higher line height, as shown in the example below:

Example

<h2>Lead Body Copy</h2> <p class="lead">This is an example demonstrating the use of lead body copy. This is an example demonstrating the use of lead body copy. This is an example demonstrating the use of lead body copy. This is an example demonstrating the use of lead body copy. This is an example demonstrating the use of lead body copy. This is an example demonstrating the use of lead body copy. This is an example demonstrating the use of lead body copy. This is an example demonstrating the use of lead body copy.</p>

Try it yourself »

The result is as follows:

引导主体副本

Emphasis

HTML's default emphasis tags <small> (sets the text to 85% of the parent text size), <strong> (sets the text to bolder text), <em> (sets the text to italic).

Bootstrap provides some classes for emphasizing text, as shown in the example below:

Example

<small>This line of content is inside the tag</small><br> <strong>This line of content is inside the tag</strong><br> <em>This line of content is inside the tag and is presented in italics</em><br> <p class="text-left">Left-aligned text</p> <p class="text-center">Center-aligned text</p> <p class="text-right">Right-aligned text</p> <p class="text-muted">This line of content is muted</p> <p class="text-primary">This line of content has a primary class</p> <p class="text-success">This line of content has a success class</p> <p class="text-info">This line of content has an info class</p> <p class="text-warning">This line of content has a warning class</p> <p class="text-danger">This line of content has a danger class</p>

Try it yourself »

The result is as follows:

强调

Abbreviations

HTML The element provides markup for abbreviations, such as WWW or HTTP. Bootstrap defines the style of the <abbr> element as a dotted border displayed at the bottom of the text, and when the mouse hovers over it, the full text is displayed (as long as you have added text to the <abbr> title attribute). To get a smaller font text, add .initialism to <abbr>.

Example

<abbr title="World Wide Web">WWW</abbr><br> <abbr title="Real Simple Syndication" class="initialism">RSS</abbr>

Try it »

The result is as follows:

缩写

Address

Use<address>tag, you can display contact information on the web page. Since<address>defaults todisplay:block;, you need to use<br>tag to add line breaks to the enclosed address text.

Example

<address> <strong>Some Company, Inc.</strong><br> 007 street<br> Some City, State XXXXX<br> <abbr title="Phone">P:</abbr> (123) 456-7890 </address> <address> <strong>Full Name</strong><br> <a href="mailto:#">[email protected]</a> </address>

Try it »

The result is as follows:

地址

Blockquote

You can use the default <blockquote> next to any HTML text. Other options include adding a <small> tag to identify the source of the quote, using the class.pull-rightaligns the quote to the right. The following example demonstrates these features:

Example

<blockquote> <p>This is a default quote example. This is a default quote example. This is a default quote example. This is a default quote example. This is a default quote example. This is a default quote example. This is a default quote example. This is a default quote example.</p> </blockquote> <blockquote>This is a quote with a source title.<small>Someone famous in <cite title="Source Title">Source Title</cite></small> </blockquote> <blockquote class="pull-right">This is a right-aligned quote.<small>Someone famous in <cite title="Source Title">Source Title</cite></small> </blockquote>

Try it »

The result is as follows:

引用

Lists

Bootstrap supports ordered lists, unordered lists, and definition lists.

  • Ordered list: An ordered list is a list that begins with numbers or other ordered characters.
  • Unordered list: An unordered list is a list without a specific order, a list that begins with traditional-style bullets. If you do not want to display these bullets, you can use the class.list-unstyledto remove the style. You can also use the class.list-inlineto place all list items on the same line.
  • Definition list: In this type of list, each list item can contain <dt> and <dd> elements. <dt> stands fordefinition term, just like a dictionary. Then, <dd> is the description of <dt>..dl-horizontalcan make<dl>the phrases and their descriptions inside line up in a row. It starts like<dl>the default styles are stacked together, and as the navbar gradually expands, they are arranged in a row.

The following example demonstrates these types of lists:

Example

<h4>Ordered list</h4> <ol> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ol> <h4>Unordered list</h4> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> <h4>Unstyled list</h4> <ul class="list-unstyled"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> <h4>Inline list</h4> <ul class="list-inline"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> <h4>Definition list</h4> <dl> <dt>Description 1</dt> <dd>Item 1</dd> <dt>Description 2</dt> <dd>Item 2</dd> </dl> <h4>Horizontal definition list</h4> <dl class="dl-horizontal"> <dt>Description 1</dt> <dd>Item 1</dd> <dt>Description 2</dt> <dd>Item 2</dd> </dl>

Try it »

The result is as follows:

列表

More Typography Classes

The following table provides examples of more Bootstrap typography classes:

Class Description Example
.lead Make a paragraph stand out Try it
.small Set small text (set to 85% the size of the parent text) Try it
.text-left Set text left-aligned Try it
.text-center Set text center-aligned Try it
.text-right Set text right-aligned Try it
.text-justify Set text justified; text in a paragraph that exceeds the screen automatically wraps Try it
.text-nowrap Text in a paragraph that exceeds the screen does not wrap Try it
.text-lowercase Set text to lowercase Try it
.text-uppercase Set text to uppercase Try it
.text-capitalize Set the first letter of each word to uppercase Try it
.initialism Text displayed in the <abbr> element is shown in a small font, and can convert lowercase letters to uppercase Try it
.blockquote-reverse Set the quote right-aligned Try it
.list-unstyled Remove the default list style, list items are left-aligned (in <ul> and <ol>). This class only applies to direct child list items (if you need to remove nested list items, you need to use this style in the nested list). Try it
.list-inline Place all list items on the same line Try it
.dl-horizontal This class sets float and offset, applied to <dl> and <dt> elements. For specific implementation, see the example. Try it
.pre-scrollable Make the <pre> element scrollable. The code block area has a maximum height of 340px. Once it exceeds this height, a scrollbar will appear on the Y-axis. Try it
Other extensions