FORMDALL & HTML

One HTML file on a static host, and still an inbox

6 min read·any HTML since 1995

There is nothing to install. You open an editor, type <!doctype html>, push the file to your web hosting over FTP or rsync, and it is live. No further step sits in between: nothing gets built or installed, and no file records which versions have to match, since there are no version numbers. The only interpreter is the browser, and the browser does not break its backwards compatibility. That is why a page from 2009 still works today, though its contact form did not work back then either.

Why a page from 2009 still works today

Plain HTML has no dependencies, so there is no toolchain anyone has to keep alive. The neighbours in this series show the difference. Eleventy and Astro depend on Node, and so on a version that will be a different one a year from now. Jekyll needs Ruby, Bundler and a Gemfile kept in shape. Hugo is pleasantly a single binary, but it renamed the layout folders in 0.146 - a change that cuts straight through every older theme. Next.js has moved through several major versions in a few years, and its rendering model with them. That is not an accusation. Tools that do something keep moving, and plain HTML does nothing.

The second part is the browser. Forms have been in the standard since HTML 2.0, so since 1995, and no vendor has decided since then to stop rendering old pages. A contact page from 2009 may look dated today, but it still loads.

The limit is not far off, and twenty pages will find it. Without templates the navigation sits in the project twenty times: a new menu entry means twenty files, a new article means creating a file and updating the index page by hand. That is what includes, partials, layouts and content collections are for. Plain HTML wins where a site is small and stays small: a landing page, a law firm site with five subpages, a project page nobody touches for two years. For those a generator buys you little and mostly leaves a dependency tree somebody has to keep current.

Three answers, and none of them works

Then you type <form into your index.html, and you have to decide what goes in the action.

The first answer you find is mailto: - the least reliable line that can sit on your page. What happens after the click is decided by the visitor’s operating system: the browser hands the address to the registered mail program. If none is registered - and for everybody who reads their mail in a browser, none is registered - nothing happens at all. There is no error message and no line in any log; the visitor hit submit, the enquiry is gone, and you never find out it existed.

If one is registered, a window opens with a draft the visitor has to send as well, and the text reads name=Anna&email=anna%40example.com&message=Hello. On top of that your address sits in the source, with mailto: in front of it, in exactly the shape address scrapers look for.

The second answer is a contact.php next to index.html. Classic web hosting runs PHP, and mail() is one line. Except that you have just restored what you did not have a moment ago: code is running on your server, on a PHP version that will eventually stop getting security updates. It accepts a POST from anyone, so you need validation, a limit and some spam defence, or in three weeks a bot is using it as a relay. And mail() sends over a shared host’s infrastructure, whose SPF and DKIM setup you have no influence over. Whether your mail arrives, lands in spam or is dropped silently is somebody else’s decision. A file you upload has turned into an application you operate.

The third answer is that there is none. On web hosting that costs two euros a month there is a document root with a server in front of it that serves files; none of that hands a request body anywhere. The POST gets a 405 back, or the same page again - the second case is the worse one, because it looks like it worked.

Plain HTML is not going to close this gap one day either, because there is no project behind it that could ship a release or a roadmap for it. The target for the POST has to come from outside.

Wiring it up

The action attribute takes an absolute URL, and it always has. Sending a form to a foreign domain is older than CORS and has never been restricted by the same-origin policy - that is why CSRF tokens exist. That is where your endpoint goes, and method stays POST.

contact.html
<!-- the endpoint sits in the markup, there is no config file -->
<form action="https://api.formdall.de/api/v1/f/kx92m4" method="POST">
  <label for="name">Name</label>
  <input id="name" name="name" required>

  <label for="email">Email</label>
  <input id="email" name="email" type="email" required>

  <label for="message">Message</label>
  <textarea id="message" name="message" rows="6"></textarea>

  <button type="submit">Submit</button>
</form>

<!-- from here on: only needed for the fetch() variant below -->
<p id="form-ok" hidden>Thanks, your message got through.</p>
<p id="form-error" hidden>That did not work. Please try again.</p>
<script src="form.js" defer></script>

The last three lines belong to the fetch() variant below; without them, what is above is the complete integration, with no JavaScript at all. There is no extra folder and no step before uploading, so you upload the file you were just editing.

After submitting, the endpoint answers with a redirect; where to is configurable per form. Here that means putting a second .html file next to the first one and entering its URL in the dashboard. You do not need routing or permalink configuration for that. The file name is the URL.

If the visitor should stay on the page instead, the second variant is a couple of dozen lines of JavaScript in a file next to it. The difference is a single header: with Accept: application/json the same endpoint answers with JSON rather than a redirect. Formdall detects it from the request; there is no second endpoint to create.

form.js
const form = document.querySelector('form');
const ok = document.querySelector('#form-ok');
const error = document.querySelector('#form-error');

form.addEventListener('submit', async (event) => {
  event.preventDefault();
  ok.hidden = true;
  error.hidden = true;

  try {
    // without this header the endpoint answers with a redirect, which fetch follows silently
    const response = await fetch(form.action, {
      method: 'POST',
      headers: { Accept: 'application/json' },
      body: new FormData(form),
    });

    const result = await response.json();

    if (response.ok) {
      form.reset();
      ok.hidden = false;
    } else {
      error.hidden = false;
      console.error(result);
    }
  } catch (networkError) {
    // network gone, DNS dead, no signal: the visitor must not miss this
    error.hidden = false;
    console.error(networkError);
  }
});

form.action reads the URL out of the markup, so the endpoint still sits in one place. I would not leave out the catch branch. Without it the listener dies silently on a network error and the visitor sees a form that does nothing - exactly what mailto: does further up. If no JavaScript runs in the browser, the form submits itself as it does in the first variant, so the script only sits on top.

You do not have to type any of it: create_form sets up the form and its fields, get_embed returns the markup - here with no template in between, so literally the way it arrives in the browser.

What you are not building

The contents of every submission sit encrypted on servers in Germany. If a form needs a captcha, the one it gets is proof-of-work that we host ourselves - that does cost you one included script, but ours. It involves no tracking and writes no cookie, and none of it travels to the US. That matters more here than elsewhere, because a plain HTML page otherwise opens no third-party connection when it loads. An off-the-shelf captcha would be the first foreign connection in it - and it would put a US service into your privacy policy and a consent banner on a page that has done without both.

You could certainly rebuild it. It just takes several things you do not have here. A server where your code is allowed to run, rather than one that hands out files. Then DKIM, SPF and DMARC for a domain that has never sent mail, and filter rules that chase whatever spammers think of next. For the forty lines of HTML that are your contact page, that is the wrong order of magnitude. Three forms and 100 submissions a month are free, and you do not need a credit card.

OR: LET THE AI DO IT
YouBuild me a contact form in plain HTML.
Assistant formdall · create_form formdall · get_embedForm created. Here is the complete markup:
<form action="https://api.formdall.de/api/v1/f/kx92m4" method="POST">
  <input name="name" required>
  <input name="email" type="email" required>
  <textarea name="message"></textarea>
  <button>Submit</button>
</form>
→ read the MCP docs

Create the endpoint, paste the action

Start for freeno credit card, ever
  • Free
  • 3 forms
  • 100 submissions/mo