Code Script πŸš€

What is the difference among col-lg- col-md- and col-sm- in Bootstrap

February 15, 2025

What is the difference among col-lg- col-md- and col-sm- in Bootstrap

Navigating the planet of responsive internet plan tin awareness similar deciphering a analyzable codification. Bootstrap, a fashionable advance-extremity model, simplifies this procedure with its intuitive grid scheme. Nevertheless, knowing the nuances of this scheme, peculiarly the quality betwixt col-lg-, col-md-, and col-sm-, is important for creating genuinely adaptable layouts. These lessons are the cardinal to controlling however your contented shows crossed assorted surface sizes, making certain a seamless person education whether or not connected a desktop, pill, oregon smartphone. Mastering these distinctions empowers you to trade web sites that not lone expression large however besides relation flawlessly connected immoderate instrumentality.

Knowing Bootstrap’s Grid Scheme

Bootstrap’s grid scheme is based mostly connected a 12-file format. This means the disposable surface width is divided into 12 close components. The col- lessons dictate however galore of these columns an component ought to inhabit. This versatile scheme permits for a broad scope of format prospects, from elemental 2-file designs to analyzable multi-file preparations.

The magic of this scheme lies successful its responsiveness. By using antithetic prefixesβ€”lg (ample), md (average), and sm (tiny)β€”you tin specify however the structure ought to accommodate to antithetic surface sizes. Deliberation of it arsenic tailoring your web site’s quality for all instrumentality, guaranteeing optimum readability and usability.

Breaking Behind col-lg-, col-md-, and col-sm-

The quality betwixt these lessons lies successful the surface measurement they mark. col-lg- applies to ample screens (usually desktops), col-md- to average screens (normally tablets), and col-sm- to tiny screens (chiefly smartphones). The asterisk () represents a figure from 1 to 12, indicating the figure of columns the component ought to span.

  • col-lg-four: Connected ample screens, this component volition inhabit four retired of 12 columns (1/three of the surface width).
  • col-md-6: Connected average screens, the aforesaid component volition inhabit 6 retired of 12 columns (1/2 of the surface width).
  • col-sm-12: Connected tiny screens, it volition inhabit each 12 columns (the afloat surface width).

This cascading attack permits for a seamless modulation betwixt layouts arsenic the surface dimension adjustments. For case, a 3-file format connected a desktop tin gracefully change into a 2-file format connected a pill and a azygous-file structure connected a smartphone.

Applicable Examples and Usage Instances

Fto’s opportunity you’re gathering a web site with a sidebar and chief contented country. You might usage col-lg-9 for the chief contented and col-lg-three for the sidebar connected ample screens. Connected smaller screens, you mightiness privation the sidebar to stack beneath the chief contented. You may accomplish this by utilizing col-md-12 and col-sm-12 for some components, guaranteeing all occupies the afloat width connected average and tiny screens.

Different illustration is a merchandise itemizing leaf. Connected bigger screens, you mightiness show merchandise successful 4 columns (col-lg-three for all). Connected average screens, you may trim it to 2 columns (col-md-6), and connected tiny screens, show all merchandise successful a azygous file (col-sm-12).

See this script: an e-commerce tract displaying merchandise playing cards. Connected ample desktops, they usage col-lg-four for a 3-file structure. Arsenic the surface shrinks to pill dimension, col-md-6 kicks successful, creating 2 columns. Eventually, connected cellular, col-sm-12 stacks all paper neatly for optimum viewing.

Champion Practices and Communal Pitfalls

Once utilizing Bootstrap’s grid scheme, it’s indispensable to program your layouts cautiously. Commencement by contemplating the contented hierarchy and however you privation it to show connected antithetic screens. Retrieve that contented volition reflow primarily based connected the viewport dimension, truthful debar hardcoding mounted widths oregon heights.

  1. Program your structure for antithetic surface sizes.
  2. Usage nested rows for much analyzable layouts.
  3. Trial your plan connected assorted gadgets.

A communal error is overusing grid lessons. Attempt for simplicity and debar pointless nesting. Retrieve, little is frequently much once it comes to responsive plan. By adhering to these champion practices, you tin make responsive web sites that are some visually interesting and extremely useful.

Infographic Placeholder: Ocular cooperation of however col-lg-, col-md-, and col-sm- impact structure crossed antithetic surface sizes.

Often Requested Questions (FAQ)

Q: What occurs if I don’t specify a col-sm- people?

A: If nary col-sm- people is specified, the component volition routinely stack vertically connected tiny screens, efficaciously occupying the afloat width.

By knowing and implementing these Bootstrap grid ideas, you tin make dynamic and person-affable internet experiences. Leveraging the flexibility of col-lg-, col-md-, and col-sm- empowers you to trade web sites that seamlessly accommodate to immoderate surface dimension, guaranteeing your contented is accessible and participating for everybody, careless of their instrumentality. Commencement gathering your responsive web site present with Bootstrap and seat the quality a fine-structured grid scheme tin brand.

  • Responsive Plan: Designing web sites to accommodate to antithetic surface sizes.
  • Cell-Archetypal: A plan attack that prioritizes cellular units.

Research additional sources connected responsive plan and Bootstrap to heighten your expertise. See exploring subjects similar grid customization, offsetting columns, and gathering analyzable layouts with nested rows. This volition let you to make equal much dynamic and participating net experiences. Fit to return your responsive plan expertise to the adjacent flat? Dive into Bootstrap’s documentation and commencement gathering!

Question & Answer :
What is the quality amongst col-lg-* , col-md-* and col-sm-* successful Twitter Bootstrap?

Up to date 2020…

Bootstrap 5

Successful Bootstrap 5 (alpha) location is a fresh -xxl- measurement:

col-* - zero (xs)
col-sm-* - 576px
col-md-* - 768px
col-lg-* - 992px
col-xl-* - 1200px
col-xxl-* - 1400px

Bootstrap 5 Grid Demo


Bootstrap four

Successful Bootstrap four location is a fresh -xl- dimension, seat this demo. Besides the -xs- infix has been eliminated, truthful smallest columns are merely col-1, col-2.. col-12, and so on..

col-* - zero (xs)
col-sm-* - 576px
col-md-* - 768px
col-lg-* - 992px
col-xl-* - 1200px

Bootstrap four Grid Demo

Moreover, Bootstrap four consists of fresh car-structure columns. These besides person responsive breakpoints (col, col-sm, col-md, and so forth..), however don’t person outlined % widths. So, the car-structure columns enough close width crossed the line.


Bootstrap three

The Bootstrap three grid comes successful four tiers (oregon “breakpoints”)…

  • Other tiny (for smartphones .col-xs-*)
  • Tiny (for tablets .col-sm-*)
  • Average (for laptops .col-md-*)
  • Ample (for laptops/desktops .col-lg-*).

These grid sizes change you to power grid behaviour connected antithetic widths. The antithetic tiers are managed by CSS media queries.

Truthful successful Bootstrap’s 12-file grid…

col-sm-three is three of 12 columns broad (25%) connected a emblematic tiny instrumentality width (> 768 pixels)

col-md-three is three of 12 columns broad (25%) connected a emblematic average instrumentality width (> 992 pixels)


The smaller tier (xs, sm oregon md) besides defines the dimension for bigger surface widths. Truthful, for the aforesaid measurement file connected each tiers, conscionable fit the width for the smallest viewport…

<div people="col-lg-three col-md-three col-sm-three">..</div> is the aforesaid arsenic,

<div people="col-sm-three">..</div>

Bigger tiers are implied. Due to the fact that col-sm-three means three items connected sm-and-ahead, until particularly overridden by a bigger tier that makes use of a antithetic dimension.

xs(default) > overridden by sm > overridden by md > overridden by lg


Harvester the courses to usage alteration file widths connected antithetic grid sizes. This creates a responsive format.

<div people="col-md-three col-sm-6">..</div>

The sm, md and lg grids volition each “stack” vertically connected screens/viewports little than 768 pixels. This is wherever the xs grid suits successful. Columns that usage the col-xs-* courses volition not stack vertically, and proceed to standard behind connected the smallest screens.

Resize your browser utilizing this demo and you’ll seat the grid scaling results.


This article explains much astir however the Bootstrap grid