[Translation] Bootstrap 3 vs 4

Jun 20, 2018 · 3 min read · 531 Words · -Views -Comments

Bootstrap released v4 on Jan 19. It introduced important changes, added new components, and removed some. Here are the differences between Bootstrap 3 and 4.

[Translation] Bootstrap 3 vs 4 - Fig 1

Original link: here

Component differences

ComponentBootstrap 3Bootstrap 4
Global
CSS source filesLESSSCSS
Main CSS unitspxrem
Media query unitspxpx
Base font size14px16px
Default font stackHelvetica Neue, Helvetica, Arial, sans-serifUses a “native font stack” (user’s system fonts), with fallback to Helvetica Neue, Arial, and sans-serif
Grid
Grid breakpoints4 breakpoints (xs, sm, md, lg)5 breakpoints (xs, sm, md, lg, xl) Bootstrap 4 removed the smallest breakpoint xs, so col- applies to all devices and you no longer need to specify sizes for that case*
OffsetsUse col--offset- e.g. col-md-offset-4Use offset-- e.g. offset-md-4
Tables
Dark tablesNot supportedAdded dark table style with .table-dark
Table header stylesNot supported.thead-light and .thead-dark
Condensed tables.table-condensed.table-sm
State classesBootstrap 3 uses .active without .table- prefix; Bootstrap 4 uses .table-active. State keywords: active, success, info, warning, dangerAdds .table- prefix for table state classes
Responsive tables.table-responsive must be on parent divSame, plus table-responsive-* for breakpoints .table-responsive-sm -md -lg -xl
Forms
Horizontal formsUse form-horizontalRemoved form-horizontal. Use .row and .form-row for grid layout
Form layout uses .control-label for gridUse col-form-label-* for grid labels
Checkbox/radio.radio, .radio-inline, .checkbox, checkbox-inline.form-check, .form-check-label, .form-check-input, .form-check-inline
Form control sizes.input-lg, input-smform-control-lg, form-control-sm
Form label sizes.col-form-label-sm, .col-form-label-lg
Help text.help-block.form-text
Validation & feedback iconsIncludes validation styles, icons via glyphiconsValidation icons removed
Legend titlesNot supportedProvides .col-form-label for legend
Static text.form-control-static.form-control-plaintext
Custom formsNot supportedSupported
Buttons
Styles.btn-secondary not availableRemoved .btn-default; added btn-secondary, btn-light, btn-dark
Outline buttonsNot supportedbtn-outline-* adds border styles
Button sizes.btn-xs available.btn-xs removed; .btn-sm, .btn-lg available
Input groups
ClassesUse .input-group-addon and .input-group-btnRemoved .input-group-addon/input-group-btn; added input-group-prepend, .input-group-append, and .input-group-text
Media object
Classes.media, .media-body etcMedia object can use flex utilities directly
Dropdowns
Structure<ul><li><ul><div> also allowed
Menu headers.dropdown-header.dropdown-header used on <h1>-<h2>, no longer in <li>
Dividers.divider.dropdown-divider
Disabled items.disabled.disabled
Button groups
Extra smallbtn-group-xs.btn-group-xs removed
Navigation
Inline nav.nav-inline
Navbar
Colors.navbar-light, .navbar-dark, and .bg-*
Alignment.navbar-right, .navbar-leftUse spacing and flex utilities
Navbar forms.navbar-formRemoved .navbar-form
Fixed navbar.navbar-fixed-top and navbar-fixed-bottomfixed-top, fixed-bottom
Pagination
Default.paginationEach <li>/<a> needs .page-item
Prev/Next.previous and .nextRemoved
Jumbotron
Full width.jumbotron.jumbotron-fluid
Glyphicons
SupportSupportedNot supported
Typography
QuotesDefault <blockquote>Introduces .blockquote on <blockquote>
Alignment.block-reverse for rightUse .text-center and .text-right
Page headerpage-header supportedpage-header not supported
Description lists.dl-horizonal for horizontal listsUse .row on <dl> and grid on <dt><dd>
Non-responsive usage
SupportSupportedNot supported
List Groups
Link/button lists.list-group-item on <a>.list-group-item-action on <a>
Collapse
Shown content.in.show
Cards
SupportSupportedNot supported
Panels
SupportSupportedNot supported
Wells
SupportSupportedNot supported
Thumbnails
SupportSupportedNot supported
Breadcrumbs
ClassUse .breadcrumbAlso require .breadcrumb-item on <li>
Carousel
Carousel item.item.carousel-item
Affix
SupportSupportedNot supported

Browser support

[Translation] Bootstrap 3 vs 4 - Fig 2

Final Thoughts

The above lists key differences; for full details, see the official docs.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover