What best practice should be followed when specifying the action attribute in a form to ensure compatibility with both HTTP and HTTPS protocols?

When specifying the action attribute in a form, it is important to ensure compatibility with both HTTP and HTTPS protocols. To achieve this, it is recommended to use a protocol-relative URL in the action attribute. This means using "//" instead of "http://" or "https://", allowing the browser to determine the appropriate protocol based on the current page's protocol. This ensures that the form submission works correctly regardless of whether the page is loaded over HTTP or HTTPS.

<form action="//example.com/form-handler.php" method="post">
  <!-- form fields here -->
</form>