Complete the code to add the Bootstrap modal class to the div.
<div class="modal [1]" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Modal title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <p>Modal body text goes here.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div>
The fade class adds a fade effect to the modal, which is part of Bootstrap's modal styling.
Complete the code to add the attribute that traps keyboard focus inside the modal.
<div class="modal fade" tabindex="-1" role="dialog" [1]> <div class="modal-dialog" role="document"> <div class="modal-content"> <!-- modal content here --> </div> </div> </div>
The aria-modal="true" attribute tells assistive technologies that the modal is active and focus is trapped inside it.
Fix the error in the button that closes the modal by completing the data attribute.
<button type="button" class="btn-close" [1] aria-label="Close"></button>
Bootstrap 5 uses data-bs-dismiss="modal" to close modals via buttons.
Fill both blanks to create a button that opens the modal with id 'myModal'.
<button type="button" class="btn btn-primary" [1]="#myModal" [2]="modal"> Launch modal </button>
In Bootstrap 5, data-bs-toggle="modal" activates the modal, and data-bs-target="#myModal" specifies which modal to open.
Fill all three blanks to create a modal div with id 'myModal', role 'dialog', and aria-labelledby 'modalTitle'.
<div class="modal fade" id="[1]" tabindex="-1" role="[2]" aria-labelledby="[3]"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="modalTitle">Modal title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <p>Modal body text goes here.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div>
The modal's id is 'myModal', the role is 'dialog' to indicate a dialog window, and aria-labelledby points to 'modalTitle' for accessibility.