How does one change the language of an HTML page? [duplicate] - html

This question already has answers here:
How to specify language of website? (HTML?)
(3 answers)
Closed 2 years ago.
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?

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

Related

Simply transfer HTML code into other HTML files [duplicate]

This question already has answers here:
Multiple webpages with common title and navigation bars
(4 answers)
Closed 2 years ago.
I would like to start a homepage for me. Every time I add a thing to index.html I have to add it to the links (in about.html etc.) as well.
How can I simplify that, that the new things of the index.html are automatically transferred directly into the other links (about.html etc.)?
Thanks for the help
The solution I used was to create a JS script that you would include in your HTML, that would add the HTML you want to the document :
let body = document.getElementsByTagName("body")[0];
body.insertAdjacentHTML("beforeend", "your html");
You could then put this script where you want to include the HTML.
I don't know if it's the best solution, but it works.
Right now, using vanilla HTML, there is no quick, easy, and simple way to do this. Using a backend framework like Django, this is easy, but that is really complicated and takes a while to learn!

how to toggle between a multiple English and Arabic in my website? [duplicate]

This question already has answers here:
How to make a Multilanguage website [closed]
(3 answers)
Closed 2 years ago.
I'm a junior front-end developer based in Egypt, so most of what I work on will be in Arabic but I will also need to support English since it is the standard website language used.
I'm looking for a solution to help my clients toggle between multiple languages. Should I build an entire project twice or what is their a better solution to switch languages on a wbeite?
Please keep in mind that I'm still a junior developer with just 2 years of experience.
You can declare the language of websites in the <html> tag, e.g. <html lang="en">. Therefore, you should be able to save your original website/project in one language and then save another copy of your website/project with the other language you'd like to show.
Read more about declaring languages in HTML
If you want to do all of this on one page only, you can use JavaScript to change the page's language using an onclick function. MDN has a good tutorial using onclick here. However, this is more complicated since you'll need to use a dictionary, such as Google's Cloud Translation API.

HTML (only), Image appears when hovering mouse over text [duplicate]

This question already has an answer here:
In HTML, how can you make an image appear while you are hovering over text?
(1 answer)
Closed 5 years ago.
can anyone tell me if it is possible to make an image appear when you hover the mouse over a text?
I'm doing a school project and I can only use html, I've seen a lot of answers but most require CSS or jQuery and other languages.
Thanks
HTML was not designed for that purpose, it was meant to give a website basic structure. It is really only used to organize and emphasis (and even that last one is mainly done from css or js) the text of a website.
Try this. The solution isn't solely HTML, but it's pretty much impossible to do what you want only using that.

Encrypt CSS style and HTML Is possible? [duplicate]

This question already has answers here:
How to disable (View Source) and (Ctrl + C ) from my site
(10 answers)
Closed 6 years ago.
My scenario is I have created a html website using inline css and also used css generator tool for menu items so any one who have good Idea in design can easily track that style is generated by tool that's why I want encrypt html and css source after rendering .
please suggest me is there any option to encrypt html or css code.
Thanks In advance.
no I would say thats not possible.
HTML and CSS are client side code which is open for all to view.
So they can't be encrypted.
Maybe look at minification, but the browser needs to interperate the code so encryption wouldn't be an option.
Here is some links to minify.
https://cssminifier.com
https://javascript-minifier.com/
If your using a CMS there are plently of minification tools.

Menu from external file [duplicate]

This question already has answers here:
What are the new frames? [closed]
(3 answers)
Closed 9 years ago.
I am now making a webpage and need a bit of help. Its been some time since Ive done my last page a few years ago. Back then I remember it was quite popular to use frames, but these days, this is basically no longer used.
What I used to do is have a horizontal menu on the top as a frame, and underneath it the content frame.
Now, currently I have a webpage again, where I would like to place a horizontal menu on the top of the page.
The menu is written in pure CSS and HTML. The CSS is loaded from an external file, but the problem I now have is that the menu is basically a DIV element, which however I have to put into each page separately.
I was just wondering there must be a way of making this simpler and have it somehow inserted from an external file again - sorry maybe it sounds confusing, but basically I am looking for an alternative of the frames used in the past. Many pages have menus and I am sure they do it somehow, because if I make a change in the menu, I dont want to be making these changes on all the hundreds of pages.
I dont ask for any specific coding etc. I can google that myself if I dont know how to do it, but I just need a general recommendation how to solve this. Just to summarize, the menu is in HTML+CSS and the pages are mostly PHP, some of them HTML.
I'd think it would mostly depend on the framework. You could just have one page, and use AJAX to load the content of each page, or you could have several php pages, all of which call some function at the beginning to set up the header, or you could use a ASP.NET master page or whatever your framework uses.
If you're using PHP, then the easiest way would be :
<?php include('my_page.html'); ?>
Be carefull of the path to your html page