I'm trying to include a link in my page that will link directly to google search results (as opposed to linking to a predetermined search, as in this question).
I tried this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
click me
</body>
</html>
The ampersand gets mangled, the url comes out as http://www.google.com%26q%3Dsports instead of http://www.google.com&q=sports.
What's the right way to do this?
I think this is format if you want to return results in the correct manner:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
click me
</body>
</html>
But here is the good resource and a duplicate to this question if that's the case - Do I encode ampersands in <a href...>?
Related
I have a simple HTML page with some <sub> elements in it. For some reason, Google Translate offers to translate the subscripts from Arabic to English (despite being English to begin with), only moving them down a little when translated. The HTML page language is set to en-US. Is this just my computer being weird, or is there a code-related reason?
<!DOCTYPE html>
<html lang="en-US">
<head>
<!--<meta name="google" content="notranslate"> (this successfully gets rid of the translate popup, commented out for testing purposes)-->
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
<title>test</title>
<link rel="icon" href="favicon.svg" type="image/svg"/>
<link href="style.css" rel="stylesheet" type="text/css"/>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="functions.js"></script>
<script src="main.js" defer></script>
</head>
<body style="min-width: 0">
<div id="test"></div>
</body>
</html>
Added to #test by JS:
<div class="letter">A<sub>1</sub></div>
Website: https://test.edgeloop.repl.co
Screenshot: screenshot
Are you sure that this is the correct code? You seem to have a <html...>-tag inside your <head>-tag. Remove the duplicate html-tag inside your head, and instead add the lang="en"-attribute to your outer-most html-tag.
Your code should thus look as follows:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<title>test</title>
....
</head>
<body style="min-width: 0">
<div id="test"></div>
</body>
</html>
If this does not immediately solve your problem, try clearing the google chrome cache as follows:
Press F12 to open the dev tools menu
Right-click your refreh-button
Select the option empty cache and hard refresh:
If your webpage uses HTML and XML interchangably, you might need to add the following to your opening <html>-tag (see this link):
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
...
</html>
If your Google Translate does still pop up, you have the following options:
add translate="no" to your root html-tag
add the class notranslate to your root html-tag
add <meta name="google" content="notranslate"> to your head-tag
Your code should look as follows:
<html lang="en" translate="no" class="notranslate">
<head>
<meta name="google" content="notranslate"/>
....
</head>
....
</html>
#Lawrence Cherone's comment about adding more text seems to fix the problem, as does #unknown6656's suggestion of adding <meta name="google" content="notranslate">. I still don't know why subscripts are considered Arabic text, but adding English text seems to fix the problem. Thanks for all the answers.
I'm just trying to post a simple html file consisting mainly of some prose I wrote inside of <pre> elements.
Interestingly, when I view the file on my computer with my browser, the quotation marks display fine. But when I upload it to my website, quotation marks are rendered as something like “ or â€. I have looked around the web for solutions but they were few and in between.
I tried to use the meta tag and included
<meta http-equiv="Content-Type" content="text/html; charset="utf-8" />
to my header but to no avail. Any ideas on how to solve this? It just wouldn't make sense to go back to the content inside the elements and code it into html as the prose is a draft and will go through many changes in the future.
The <!doctype html> tag indicates the file is HTML5 - so the browser will render it as such. lang="en" should be set to the language you are working with. Be sure to use the <meta charset="utf-8"> tag to set the character set in the <head>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Template</title>
</head>
<body>
<pre>This is my stuff</pre>
</body>
</html>
Check your code with the browser's View Source and use the Validator at https://validator.w3.org/ to check the page.
Here what I tried.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<pre>Einstein said,"Once you stop learning, you start dying"</pre>
</body>
</html>
I also tried only this
<body>
<pre>Einstein said,"Once you stop learning, you start dying"</pre>
</body>
Still working
I uploaded my website and one of the tab(more info) is in chinese for some reason and I dont know why. here is the the url http://bushdid911.net
http://pastebin.com/jFBUV1ga
At very least, you should add
<meta charset="utf-8">
to the html's <head> section.
A (very, very) basic html template you should use is
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page title</title>
</head>
<body>
</body>
</html>
Another reason could be that Bush did this, too. Just to create another conspiracy theory..
I feel really stupid, but I can't for the life of me find my title or meta tags in my source code. It just starts out
<!DOCTYPE html>
<head>
.....
</head>
<body>
...
and then continues like that. I know my title is set, because it's displaying in my tab. This link (https://help.yahoo.com/kb/yahoo-web-hosting/SLN18260.html?impressions=true) tells me the meta tags should be right under the title. So where is the title??? I just want to make sure my meta tags are printing as expected.
UPDATE:
Weird, I just found them like halfway down the page, way outside my <head>. I don't know what they're doing there, but at least I found them.
This is the procedure,
<!DOCTYPE HTML>
<html>
<head>
<title>...</title>
<meta charset="UTF-8">
<meta name="keywords" content=".." /> //if needed
<meta name="description" content=".." /> //if needed
</head>
<body>
.....
</body>
</html>
The <title></title> should be inside the <head></head> block.
Code does not automatically generate tags. Thus, to create a title and meta tag, just initiate them below the head (following convention):
<!DOCTYPE html>
<head>
<title>My Website</title>
<meta charset="UTF-8">
</head>
<body>
</body>
a proper HTML structure should be like..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>My title</TITLE>
</HEAD>
<BODY>
......
</BODY>
</HTML>
HERE is the reference to get more ideas about HTML.
I want to display a special caracter but when i used <h2></h2> this caracter does not appear on the web-site page.
<h2>Aéroport Tunis Carthage </h2>
on the web-site the text is: Arport Tunis Carthage.
<h2>Aéroport Tunis Carthage</h2> will do it.
Handy info on encoding can be found here and info on html character entities here.
There are two ways for displaying special characters in HTML:
1) Using HTML entities. For example:
Aéroport
2) Encoding the source HTML file appropriately (e.g. using UTF-8) and then indicating such encoding in the HTML head:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h2>Aéroport Tunis Carthage </h2>
</body>
</html>
Of course, you have to use a text editor capable of writing files in the desired encoding. Otherwise you should indicate in the <head> the encoding used by the editor.
Try adding this to your meta tags:
HTML4:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
HTML5:
<meta charset="UTF-8">
Source:
http://www.w3schools.com/tags/att_meta_http_equiv.asp
EXAMPLE:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta Tag -->
<meta charset="UTF-8"> <!-- HTML5 -->
<title> Your title here </title>
</head>