html - How do I use the <legend> element with styles? -


i ran quirky problem , haven't been able find answer or figure out.

the problem regarding <legend> tag within <form>.

i've created form using <form> , when use <fieldset> <legend> nested inside, page renders normally, fine!

when use <form> without <fieldset> continue use <legend>, page breaks.

specifically, <legend> text not conform style applied <body> under <style>. instead of centering text, it's on left. (see code..)

this stupid on part yeah, i'm stumped. thing can think of <legend> cannot used on own (without element <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 reading this, well, we've 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>

legend must placed within fieldset. table , related elements, can't have td or th without tr.

there funny fact legend element lot of people don't know if place legend anywhere within fieldset show on top of fieldset. tfoot inside table, render after tbody if placed on top in html.

example:

<fieldset>      <span>content</span>      <legend>title</legend>  </fieldset>

even though <legend> element above written after <span> element, still renders @ top of <fieldset> element.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -