Utilities and responsive rules
Use display, flex and spacing utilities to adapt the same markup across breakpoints.
What you will be able to do
- Use d-none and d-md-block for responsive visibility.
- Use flex utilities for alignment and wrapping.
- Use text-center and text-md-start for responsive text alignment.
- Extract repeated combinations into your own component class.
In plain English
Utilities are single-purpose classes that you compose. Responsive variants add a breakpoint, such as d-none d-md-block. Keep utility soup readable by grouping related classes and extracting repeated combinations into components.
<div class="d-flex flex-column flex-md-row align-items-md-center gap-3">
<div class="flex-grow-1">
<h1 class="h4 mb-0">Responsive header</h1>
</div>
<button class="btn btn-primary d-none d-md-inline-block" type="button">New</button>
</div>Your turn
EasyResponsive text alignment
Centre a heading on mobile and align it to the start from md up.
HTML · starter
<h1>Check your understanding before moving on.
Knowledge checkQuestion 1
What does d-none d-md-block do?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.