I just ran into a quirky problem and haven't been able to find an answer or figure it out.
The problem is regarding the <legend>
tag within a <form>
.
I've created a form using <form>
and when I use <fieldset>
with <legend>
nested inside, the page renders normally, just fine!
When I use <form>
without <fieldset>
but continue to use <legend>
, the page breaks.
Specifically, the <legend>
text does not conform to the style I applied to <body>
under <style>
. Instead of centering the text, it's on the left. (see code..)
This is probably something really stupid on my part but yeah, I'm stumped. The only thing I can think of is that <legend>
cannot be used on its own (without an element like <fieldset>
).
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Misha's Homepage</title>
<style>
body {
background-color:black;
text-align:center;
color:white
}
</style>
</head>
<body>
<h1>Welcome!</h1>
<hr>
<p title="Carpe Diem">If you are reading this, well, we've only just begun.</p>
<h2>Stay Hungry...</h2>
<h3>Stay Foolish!</h3>
<a href="https://youtu.be/2fAP-5NVZAA">Velocidas Eradico</a>
<h1>Squad Up!</h1>
<img src="ak_cartoon_whiteONclear2.jpg" alt="Get Sum." style="width:302px;height:217px">
<form>
<legend>Gimme Yo Digitz!</legend>
<br>First Name:
<br>
<input type="text" name="firstname">
<br>Last Name:
<br>
<input type="text" name="lastname">
<br>
<br>Choose:
<br>
<input type="radio" name="state" value="bored">Bored
<br>
<input type="radio" name="state" value="sleepy">Sleepy
<br>
<input type="radio" name="state" value="horny">Horny
<br>
<br>
<input type="submit" value="Hit it!">
</form>
</body>
</html>