sanjar-notes / web_dev_fundamentals

The basics - HTML, CSS, Javascript and more
https://sanjar-notes.github.io/web_dev_fundamentals/
3 stars 0 forks source link

`form` attribute #70

Open sanjarcode opened 1 year ago

sanjarcode commented 1 year ago

form attribute: <form id=""> and <input form=""> outside the form

HTML5 ftw, https://www.impressivewebs.com/html5-form-attribute/

As opposed to Portaling, ref, CSS gymanstics.

Situation

In a slider (volopay-v2-core-slider) expects children of the form:

<>
   <SomeContent />
   <TheFooter />
</>

Problem

What to do when the content is a form and footer has the button? The following:

<form>
   <SomeContent />
   <TheFooter />
</form>

messes up the footer styles (fixed to bottom CSS we have). There's no other markup solution

Solution

HTML5's form attribute to the rescue!

Change: add an id to <form />, then add the form attribute with the id to buttons in the footer. That's all