Modals are streamlined, but flexible, dialog prompts with the minimum required functionality and smart defaults.
Due to how HTML5 defines its semantics, the autofocus
HTML attribute has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript:
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus();
});
More Information in the WCAG 2.0 Guidelines
Notes
- Be sure not to open a modal while another is still visible. Showing more than one modal at a time requires custom code.
- Always try to place a modal's HTML code in a top-level position in your document to avoid other components affecting the modal's appearance and/or functionality.
- There are some caveats regarding using modals on mobile devices. See Bootstrap's browser support docs for details.