Bootstrap modals add a semi-transparent backdrop that covers the page behind the modal. This backdrop blocks mouse clicks on the background. Also, keyboard focus is trapped inside the modal, so users cannot tab to elements outside it. This combination keeps user attention on the modal content.
The tabindex="-1" attribute on the modal container allows JavaScript to set focus to the modal when it opens. This helps trap keyboard navigation inside the modal, preventing focus from moving to background elements.
Bootstrap adds a semi-transparent dark backdrop behind the modal. This dims the rest of the page, making the modal stand out visually and focusing user attention on it.
The aria-modal="true" attribute indicates that the modal is a modal dialog and that the rest of the page content is inert. This helps screen readers focus on the modal content and ignore background content.
The backdrop element added by Bootstrap has the class modal-backdrop. Using .modal-backdrop in CSS targets this overlay for styling.