Skip to main content

HTML Guide

Bad value for attribute “action” on element “form”: Percentage ("%") is not followed by two hexadecimal digits.

The issue here is related to the encoding of URLs. In HTML and URLs, special characters that have specific meanings need to be encoded to ensure that the URL is interpreted correctly. This process converts characters to their percent-encoded form, where a character is replaced by % followed by two hexadecimal digits representing the ASCII code of the character.

Explanation:

  • The action attribute of a <form> element specifies where to send the form-data when a form is submitted.
  • If the URL contains special characters (e.g., spaces, <, >, #, %, etc.), they need to be percent-encoded. For instance, a space character is encoded as %20.
  • In this case, the validator is complaining about a % sign that is not correctly followed by two hexadecimal digits, which typically happens if the URL was not properly encoded.

How to Fix:

  1. Check the URL: Look for any raw special characters that need encoding.
  2. Correctly Encode the URL: Use online tools or libraries that provide URL encoding support to ensure that the URL is correctly percent-encoded.

Example:

Suppose you have the following incorrect form tag:

<form action="submit%data.html">
  <!-- form elements here -->
</form>

The % in submit%data.html should be followed by two hexadecimal digits. If %data was intended to be a part of the URL, it should be encoded properly. Here is how to correct it:

<form action="submit%25data.html">
  <!-- form elements here -->
</form>

If % should represent data, replace % with %25, which is the percent-encoded form of %. Always verify each special character is correctly encoded. Using this approach ensures that the URL in the action attribute is valid according to HTML standards.

Related W3C validator issues