Ask coding questions

← Back to all posts
<!DOCTYPE html> command not working
ejtack (0)
<!DOCTYPE html>
<html>

<head>
	<title>Links</title>
</head>

<body>
	<h1>Links</h1>
</body>

</html>

That code snippet isn't working. I'm doing a tutorial from Interneting is Hard | Links and Images Tutorial
When I type in the

<!DOCTYPE html>

command, it shows up like this:

How do I fix this because whenever this happens, I cannot view the viewable elements in the webpage and it says it doesn't exist.

Answered by IcynDevz (724) [earned 5 cycles]
View Answer
Comments
hotnewtop
IcynDevz (724)

You shouldn't delete the default code when you create a new HTML repl. Copy this and paste it in.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <script src="script.js"></script>
  </body>
</html>
ejtack (0)

@IcingHackz

You shouldn't delete the default code when you create a new HTML repl. Copy this and paste it in.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <script src="script.js"></script>
  </body>
</html>

Thank you so much! I had deleted index.html in one of my earlier projects, and it still worked so I couldn't choose that as the best answer. I guess I will just stick with the basic code and just delete the meta values and script element because of the tutorials' instructions.

Baconman321 (1050)

Ok, so web servers normally will serve a default "index.html" in a folder. Since you renamed "index.html" to "links.html" it is trying to serve the index but the index doesn't exist. Navigate to https://links-and-images.ejtack.repl.co/links.html instead. I should also mention that <!DOCTYPE html> is meant to specify to browsers what type of document they are readying. Most browsers already infer this, so it isn't a big deal if you leave it out.

The way the <!DOCTYPE html> shows up is just the syntax highlighter. To view the webpage you have to navigate to the webpage; the url is shown at the top of the preview box.

Like I said though, you don't have an "index.html" so it's trying to serve "index.html" which doesn't exist, thus giving a 404. Rename "links.html" to "index.html" and it will properly.

RYANTADIPARTHI (6006)

when you open a repl, the html should be there. Use that.

Coder100 (16759)

lol why in the world did you 'diagnose' it to the doctype HTML?

xd

Your problem is that you somehow deleted the index.html file (???), and the default page of any website is index.html.

https://replit.com/@Coder100/BelovedLowestJava-working-repl-as-u-can-see#index.html