In bootstrap we have two different ways through which we can display a code. The following are the ways through which code can be displayed in bootstrap:
- By using the < code> tag. If the user wants to display the code inline then he should use the <code> tag.
- By using the <pre> tag. If the user wants to display the code in multiple lines or the code has a number of lines then the <pre> tag should be used.
When the <code> and <pre> tags are used it should be ensured that you are using the Unicode variants for both opening and closing tags. The Unicode variants are < and >.
Consider the following example in which we have used the <code > and < pre> tags along with the Unicode variants:
<! DOCTYPE html >
<title> Bootstrap Example </ title >
<linkhref = “/ bootstrap / css/ bootstrap. min. css” rel = “stylesheet” >
<scriptsrc = “/ scripts/ jquery. min. js” ></ script >
<scriptsrc = “/ bootstrap /js / bootstrap. min. js” >< /script >
</ head >
<p><code><br></code> is used to generate a line break.
<p>The <pre> tag is used to display the code in multiple lines.
<h1>Heading of the article</h1>
</ body >
The above code will generate the following result:
It can be seen in the above example the code in one line the <code> element is used and the Unicode variants are used to display the coding on the webpage. To display the code on multiple lines on the page we used the <pre> tag and to display the tags on the webpage Unicode variants are used.