Twitter Bootstrap: Text in navbar
For adding non-hyperlinked text to your Bootstrap navbar, use the .navbar-text
class. It appropriately styles your text, making it consistent with the navbar's look and feel:
This text blends seamlessly with the navbar, eliminating the need for custom CSS.
Styling options for your navbar text
Inline or block styling
Navbar text can be styled as either inline or block. For inline styling, use <span>
while <p>
provides the block styling you need. The choice impacts how your text wraps and influences the display of surrounding items:
Text emphasis sans linking
If you need to highlight the text without creating an active link, wrap a heading tag (like <h5>
) inside the <span>
:
This accomplishes emphasis while preventing accidental redirections (because who needs that?).
Text as part of navigation items
Are you looking to include unlinked text as a navigation item? Use the .nav-item
class with the text, improving navbar logic and design harmony:
This trick provides visual consistency when combined with clickable nav-link elements.
Breaking down the styling puzzle
Responsiveness wins
Designing navbars to be responsive means your text should comfortably fit different screens. With Bootstrap, we get responsive navbar classes that help keep the look intact:
The collapsible feature pairs with the text, served as a responsive navbar - larger screens to the right, smaller screens to the center.
Delve into GitHub
Ever felt stuck, like a cat in a dog show? Check out Github's Issue 2799 for more tooltips, tricks, and workarounds provided by the community on quirky Bootstrap navbar scenarios.
Keeping up with Bootstrap
Ensure to familiarize with the latest Bootstrap documentation. Fresh features afford better solutions for embedding text in the navbar.
Was this article helpful?