FAQ: Learn Bootstrap 4: Utilities and Components - The Button Component

This community-built FAQ covers the “The Button Component” exercise from the lesson “Learn Bootstrap 4: Utilities and Components”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Bootstrap

FAQs on the exercise The Button Component

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi, my question is about the type = "button" bullet point in this exercise. I see that in the intro, we are supposed to add type="button" to our buttons, but underneath, in the instructions of the exercise, we only have to apply two classes, btn to give the element Bootstrap’s default button styling and btn-danger which as an example, makes the button red, and we do not have add type = "button". Is type only for screen readers? Do we always need to add a type to our buttons in Bootstrap? Elsewhere on the official Bootstrap website I noticed that sometimes we might add role = "button" instead. Which is (more) correct and when is it necessary?

Intro from the exercise vs. Instructions below:

The example above will render a red button that has the text Danger inside the button:
:star: It has a type of "button" .
:star: It has two classes, "btn" and "btn-danger" .

  • The "btn" class provides Bootstrap’s default button styling.
  • The "btn-danger" turns the button red and conveys the purpose of the button, i.e. clicking this button might not be safe!

–VS–

  1. For the Click here for more info button, it already has a class of "btn" . We want to add a class to give this button a teal color.
    According to the Bootstrap’s button examples we need to add the class "btn-info" to make it teal.

Thanks in advance! :smiley: