In this tutorial, we're going to delve into the text utilities and alignment techniques provided by Bootstrap, a popular front-end framework. Text is a crucial part of any website, and Bootstrap provides us with a range of utilities to manipulate and showcase text in an attractive and readable way.
Bootstrap provides us with several CSS classes to manipulate text. These are:
.text-left
, .text-right
, .text-center
, and .text-justify
..text-lowercase
, .text-uppercase
, and .text-capitalize
..text-primary
, .text-success
, .text-danger
, .text-warning
, .text-info
, .text-light
, .text-dark
, and .text-muted
..font-weight-bold
, .font-weight-normal
, .font-weight-light
, .font-italic
, and .text-monospace
.<!-- Text aligned to the left -->
<p class="text-left">This is a left-aligned text.</p>
<!-- Text aligned to the right -->
<p class="text-right">This is a right-aligned text.</p>
<!-- Text centered -->
<p class="text-center">This is a centered text.</p>
<!-- Justified text -->
<p class="text-justify">This is a justified text.</p>
<!-- Lowercase text -->
<p class="text-lowercase">This is a lowercase text.</p>
<!-- Uppercase text -->
<p class="text-uppercase">This is an uppercase text.</p>
<!-- Capitalized text -->
<p class="text-capitalize">This is a capitalized text.</p>
<!-- Text in primary color -->
<p class="text-primary">This is a primary-color text.</p>
<!-- Bold text -->
<p class="font-weight-bold">This is a bold text.</p>
<!-- Light text -->
<p class="font-weight-light">This is a light text.</p>
In this tutorial, we've learned how to manipulate and align text using Bootstrap's CSS classes. We've seen how to align text to the left, right, center, and justify it. We also covered how to change the color, weight, and transformation of the text.
To learn more about Bootstrap's text utilities, you can visit the official Bootstrap documentation.
Now, it's your turn to practice. Here are some exercises:
<p class="text-right">This text is aligned to the right.</p>
<h1 class="text-uppercase font-weight-bold">This is an uppercase and bold heading.</h1>
<p class="text-warning font-italic">This text is italic and colored with the warning color.</p>
Keep practicing and exploring the Bootstrap documentation for more utilities and features!