Set the id of an element:
- In addition to classes, each HTML element can also have an id attribute.
- There are several benefits to using id attributes.
- You can use an id to style a single element.
- id attributes should be unique. Browsers won't enforce this, but it is a widely agreed-upon best practice. So please don't give more than one element the same id attribute
- Here's an example:
<h2 id="name-of-your-choice">
- A real-time example of this code is:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Checkbox</title>
</head>
<div class="silver-background">
<body>
<p class="blue-text" id="personality-test"> What kind of people do you love</p>
<label for="Loving"><input id="Loving" value="Loving" type="checkbox" name="Loving-Funny-Serious-Bodybuilder"> Loving</label>
<label for="Funny"><input id="Funny" value="Funny" type="checkbox" name="Loving-Funny-Serious-Bodybuilder"> Funny</label>
<label for="Serious"><input id="Serious" value="Serious" type="checkbox" name="Loving-Funny-Serious-Bodybuilder">Serious</label>
<label for="Bodybuilder"><input id="Bodybuilder" value="Bodybuilder" type="checkbox" name="Loving-Funny-Serious-Bodybuilder">Bodybuilder</label>
</body>
</div>
</html>
No comments:
Post a Comment