English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Bootstrap allows you to display code in two ways:
The first one is the <code> tag. If you want to display code inline, then you should use the <code> tag.
The second one is the <pre> tag. If the code needs to be displayed as an independent block element or if the code has multiple lines, then you should use the <pre> tag.
Please ensure that when you use the <pre> and <code> tags, the start and end tags use the unicode variant: < and >.
Let's take a look at the following example:
The example is shown as follows:
Element/Class | Description | Example |
---|---|---|
<var> | Variable assignment: x = ab + y | Try It |
<kbd> | Key提示: CTRL + P | Try It |
<pre> | Multiple lines of code | Try It |
<pre> | Multiple lines of code with a scrollbar | Try It |
<samp> | Computer program output: Sample output | Try It |
<code> | Same line code snippet: span, div | Try It |