How can I append the "lang" attribute of the HTML tag on a specific page in Webflow for my multilingual website?

TL;DR
  • Open the page settings in Webflow and add a script like document.documentElement.lang = "xx"; in the Custom Code head section.  
  • Save and publish the site to apply the per-page language setting dynamically.

To set the lang attribute of the HTML tag for a specific page in Webflow (e.g., for a multilingual site), you’ll need to use custom code since Webflow doesn’t allow direct editing of the HTML <html> tag in the Designer.

1. Use Custom Code in Page Settings

  • Go to the Webflow Pages panel and click the gear icon next to the specific page you want to edit.
  • Scroll to the Custom Code section in the page settings.

2. Add JavaScript in the <head> Section

  • In the Inside <head> tag field, paste the following small inline script:

  <script>document.documentElement.lang = "es";</script>

  • Replace "es" with the correct language code for the page (e.g., "fr" for French, "de" for German).

3. Publish Your Site

  • Save changes, then publish your site to see the effect.
  • Use browser dev tools to inspect the <html> tag and verify the lang="es" (or your chosen code) is applied.

Summary

To set the lang attribute dynamically for a specific page in Webflow, inject a small script like document.documentElement.lang = "xx"; in the page’s custom code section. This method allows per-page language settings without needing full code export.

Rate this answer

Other Webflow Questions