HTML checked-Attribut
Das HTML checked-Attribut ist ein boolesches Attribut und gibt an, dass ein <input>-Element beim Laden der Seite markiert sein muss.
Sie können dieses Attribut nur auf dem <input>-Element (<input type="checkbox"> und <input type="radio">) verwenden.
Es ist auch möglich, das checked-Attribut nach dem Laden der Seite mit JavaScript festzulegen.
Syntax
html
<input type="checkbox|radio" checked>
<input type="checkbox|radio" checked="checked">Beispiel für das HTML checked-Attribut:
HTML checked-Attribut
html
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h2>HTML Form Example</h2>
<form action="/form/submit" method="post">
<input type="radio" name="game" value="football" checked /> Football
<input type="radio" name="game" value="basketball" /> Basketball
<input type="submit" value="Submit" />
</form>
</body>
</html>Practice
Was bewirkt das HTML-'checked'-Attribut?