Every bootstrap web page must have the follow code structure:
- Page must have HTML5 doctype
- Meta viewport tag
- Container
Page must have HTML5 doctype
Every web page must start with HTML5 doctype along with the
lang
attribute and correct character set.
The code is set in the following structure implies that the browser is told to please render the page with HTML 5 compatible mode. So that bootstrap page will render properly in browser and gives expected output.
[html]
<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
</body>
</html>
[/html]
As known, Bootstrap 3.0 is mobile first technology.
Before starting actual body content, tell to the browser to set proper view port of rendering device.
[html]
<meta name="viewport" content="width=device-width, initial-scale=1">
[/html]
width=device-width
: With this attribute, the browser will set the width of webpage to the width of device.
initial-scale=1
: With this attribute, the browser will set initial zoom level when the page is first loaded.
Normally, the body content is placed in between
html body tag but if bootstrap is used, there are two special classes to wrap the content, they are
.container
and
.container-fluid
.container
: It will add the responsive feature to the website with fixed width and keeps the content in middle of the browser.
.container-fluid
: It will provide the fluid width and utilizes the entire browser's width. In the next chapters, detailed difference between the two classes will be discussed.