What Are Attributes, and How Do They Work?

The last question in this section does not have a correct answer.
Which of the following is the correct syntax for a boolean attribute?
Choices:

<input type="checkbox" checked>
<input type="checkbox" checked="on">
<input type="checkbox" checked="off">
<input type="checkbox" checked="isChecked">

The correct answer should be:
<input type="checkbox" checked />

the /> does not make the syntax correct or incorrect, it’s used on void elements but it’s not necessary

1 Like

The slash is completely ignored by the parser.

Self-closing tags

Self-closing tags (<tag />) do not exist in HTML.

If a trailing / (slash) character is present in the start tag of an HTML element, HTML parsers ignore that slash character.

I thought you always had to use a closing tag with / unless it was a void element.

An input element is a void element.

you need to use the closing tag </elementName> on all elements unless they are void elements, input elements are void elements so they don’t want the closing tag