1 hour ago · Tech · hide · 0 comments

If anything looks wrong, read on the site! Ok, this is maybe something that is widely known (it sure feels like it should be), but it was a gap in my knowledge at least, due to being self-taught: HTML <form> controls don’t have to be inside the <form> tag! All my web dev life, I always thought that any fields of a form necessarily had to be inside the <form> it belongs to, otherwise it’d rely on JavaScript to work, which is gross. Which is how I ended up with structures similar to the one below, from a blog archive page: <form action="/"> <section class="hero"> <!-- Search input and category filters --> </section> <!-- Other blocks like featured posts --> <section class="posts-feed"> <!-- blog posts, pagination, extra filters, etc --> </section> </form> The content in between the hero and posts-feed is flexible and controlled from the CMS, which means it can contain any other components in it. To account for that, I wrapped the entire content of the page in a <form>, so that the…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.