Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap Typography

Bootstrap Typography

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

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


Title

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 »

The result is as follows:

Inline subtitles

To add an inline subtitle to any heading, simply add a around the element, or add the , or add the .small class, so you get smaller, lighter-colored text, 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 »

The result is as follows:


Lead body copy

To add emphasized text to a paragraph, add class="lead", which gives 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 »

The result is as follows:


Emphasis

HTML's default emphasis tags (sets text to 85% of the parent text size),(sets text to bolder text),(sets text to italics).

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

Example

<

small

The content on this line is inside the tag

small

<

br

<

strong

The content on this line is inside the tag

strong

<

br

<

em

The content on this line is inside the tag and rendered in italics

em

<br>
<p class="text-left">

Left-align text

p

<p class="text-center">

Center-align text

p

<p class="text-right">

Right-align text

p

<p class="text-muted">

The content on this line is de-emphasized

p

<p class="text-primary">

The content on this line has a primary class

p

<p class="text-success">

The content on this line has a success class

p

<p class="text-info">

The content on this line has an info class

p

<p class="text-warning">

The content on this line has a warning class

p

<p class="text-danger">

The content on this line has a danger class

p

Try it »

The result is as follows:


Shorthands

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

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

tag, you can display contact information on a web page. Since
defaults to display:block;, you need to use the
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:#" mailto@somedomain.com a address>

Try it »

The result is as follows:


Blockquote

You can use the default alongside any HTML text

. Other options include adding a tag to identify the source of the quotation, and using the class .pull-right to right-align the quotation. The example below demonstrates these features:

Example

<

blockquote

<

p

This is a default blockquote example. This is a default blockquote example. This is a default blockquote example. This is a default blockquote example. This is a default blockquote example. This is a default blockquote example. This is a default blockquote example. This is a default blockquote example.

p

blockquote

<

blockquote

This is a blockquote 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 blockquote.

<

small

Someone famous in

<

cite

title

=

"

Source Title

"

Source Title

cite

small

blockquote

Try it »

The result is as follows:


List

Bootstrap supports ordered, unordered, 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 with no specific order, beginning with traditional-style bullets. If you don't want to show these bullets, you can use the class .list-unstyled to remove the style. You can also use the class .list-inline to place all list items on the same line.
  • Defines a list: In this type of list, each list item can contain
    and
    .
    Representing a definition term, like in a dictionary. Then,
    Is
    description..dl-horizontal can make
    the phrase and its description inside align on one line. It starts like
    the default style stacked together, and as the nav bar gradually expands, arranged in one line.

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

Defines a 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 table below 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% of parent text size) 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 alignment; text in a paragraph that overflows the screen wraps automatically Try it
.text-nowrap Text in a paragraph that overflows 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 Capitalize the first letter of each word Try it
.initialism Displayed in elements, the text is shown in a small font, and lowercase letters can be converted to uppercase Try it
.blockquote-reverse Set a blockquote right-aligned Try it
.list-unstyled Remove the default list style; list items are left-aligned within
    and
      ). 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 floats and offsets; applied to
element and
elements; see the example for the specific implementation
Try it
.pre-scrollable Make
 元素可滚动,代码块区域最大高度为340px,一旦超出这个高度,就会在Y轴出现滚动条
Try it