The purpose of a <form>
element, IMO, is semantic not presentational - the element is there to define an area with elements which can be sent to the server.
Why then, does the browser (and, I assume in the spec), specify display:block in the user agent stylesheet? Surely, if you want to have the form be a block, you can just wrap it in a div element?
Usually, I just put form { display: inline } into my css to override this. Still, I'm wondering if there was a good reason for making the <form>
display as a block by default, or if it's just been kept that way for legacy reasons.
HTML 3.2 defines the <FORM> element as a block level element. The current behaviour of browsers regarding this element is certainly for backwards compatibility.
So what is a block-level element? A block-level element is an HTML element that begins a new line on a web page and extends the full width of the available horizontal space of its parent element. It creates large blocks of content like paragraphs or page divisions. In fact, most HTML elements are block-level elements.
# aside. Defines a block of content that is related to the main content.
The form element inserts a component designed to contain controls that users can interact with to send information back to the server. This element is commonly used to gather information from the visitors of a website, like preferences, comments, opinions and a lot more.
I assume this is because a <form>
will very often contain other block level elements (div's for structure, or though I cringe at the thought, tables to help organize form fields, etc.). And having an inline element that contains block elements, while entirely possible, is semantically questionable.
I completely agree with your point about <form>
not being presentational, but at the same time it makes sense to me that it would be a block element, given how the tag is generally used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With