Below you'll find a snippet of code:
<form>
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
<div class="form-group">
<label class="form-check-label"><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
While I understand the purpose of an id
and a class
attribute, I'm puzzled by why both are used in the same element.
For instance, in the code above, the input has a class="form-control"
and an id="inputPassword"
.
I'm seeking a clarification on when and why this combination is used, as I personally would typically only use the class and not the id in this scenario.