Search code examples
htmlamp-html

How does one change the language of an HTML page?


Specifically, I am writing in AMP HTML, if there would be any conflictions.

I would like to approach a pretty cool concept of being able to change the language of an HTML page I am working on, just by the click of a button, like so:

<button>Parlez-vous Français?</button>

I would like the person do be able to click a button that would specifically translate the page into French. But it would be cool to add some animation to it too, like maybe a fade-out/fade-in sort of thing.

How would I be able to approach this?


Solution

  • You can simply change it in the HTML tag itself

    <html lang="fr">
    ...
    </html>
    

    considering you know that it's an html attribute. There are many ways you can change it. Storing the change can either be on database or session storage. Hope this helps