The term "legend" was referenced in the title and the image appears to mimic a <fieldset>
, but Bootstrap has altered the fieldset rendering it unrecognizable. Below is the code snippet with Bootstrap classes applied to create a fieldset that actually looks like a fieldset:
<fieldset class="border rounded p-2">
<legend class="float-none w-auto"></legend>
</fieldset>
I made adjustments by adding .h6
and .mb-0
to the <legend>
to reduce the font-size
and margin-bottom
. Do you really require a <label>
, or are you including more form controls within the fieldset?
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b4944445f585f594a5b6b1e051a0518">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">
<style></style>
</head>
<body>
<main class="container">
<section class="row">
<form>
<fieldset class="border rounded p-2">
<legend class="float-none w-auto mb-0 h6">Select State of Registration: </legend>
<input id='state' name="state" class="form-control" list="state-list" placeholder='State'>
<datalist id="state-list">
<option value="San Francisco">
<option value="New York">
<option value="Seattle">
<option value="Los Angeles">
<option value="Chicago">
</datalist>
</fieldset>
</form>
</section>
</main>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4d2f2222393e393f2c3d0d78637c637e">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<script></script>
</body>
</html>