Content components in Bootstrap 4 are reserved for the most commonly used HTML elements such as images, tables, typography, and more. In this chapter, I'll teach you how to use all the building blocks of HTML that you'll need to build any type of website or web application. We'll start with a quick overview of each component and then we'll build it into our blog project. Bootstrap 4 comes with a brand new CSS reset called Reboot. It builds on top of Normalize.css to make your site look even better out of the box. Before we jump in, let's review some Reboot basics when dealing with content components in Bootstrap 4.
Let's start this chapter by reviewing the basics of Reboot when using content components in Bootstrap. One of the main changes for content components in Bootstrap 4 is the switch from em to rem units of measure. rem is short for root em and is a little bit different from a regular em unit. em is a relative unit to the font-size of the parent element it is contained within. This can cause a compounding issue in your code that can be difficult to deal with when you have a highly nested set of selectors. The rem unit is not relative to its parent, it is relative to the root or HTML element. This makes it much easier to determine the actual size of text or other content components that will appear on the screen.
The box-sizing property is globally set to border-box on every element. This is good because it ensures that the declared width of an element doesn't exceed its size due to excess margins or padding.
The base font-size for Bootstrap 4 is 16px and it is declared on the html element. On the body element, the font-size is set to 1rem for easy responsive type-scaling when using media queries.
There are also global font-family and line-height values set on the body tag for consistency through all components. By default, the background-color is set to #fff or white on the body selector.
There are no major changes to the styles for headings and paragraphs in Bootstrap 4. All heading elements have been reset to have their top-margin removed. Headings have a margin-bottom value of 0.5rem, while paragraphs have a margin-bottom value of 1rem.
The list component comes in three variations: <ul>, <ol>, and <dl>. Each list type has had its top-margin removed and has a bottom-margin of 1rem. If you are nesting lists inside one another, there is no bottom-margin at all.
This typography style is used for displaying blocks of code on a website using the <pre> tag. Like the previous components, its top-margin has been removed and it has a bottom margin of 1rem.
The table component has been adjusted slightly to ensure consistent text alignment in all cells. The styles for the <caption> tag have also been adjusted a bit for better legibility.
The form component is much simpler in Bootstrap 4. Much of the default styling has been removed to make the component easier to use and customize. Here are some of the highlights you should be aware of:
<fieldset> tag. The borders, padding, and margin are no longer there.<legend> tag has been simplified and is much more minimal in look now.<label> tag is now set to display: inline-block to allow margins to be added.<input>, <select>, <textarea>, and <button>.<textarea>s can now only be resized vertically. They can't be resized horizontally, which often breaks page layouts.That covers the key elements you need to be aware of with Reboot. If you're interested in learning more, please check out the docs at http://v4-alpha.getbootstrap.com/content/reboot/ .
Now that we've reviewed the Reboot CSS reset, it's time to actually start covering the content components and adding them to our blog project.