user17949931
user17949931

Reputation:

Trouble starting with HTML. Can't open new html file in browser

I am at the very beginning of learning HTML, but I am having trouble opening the new HTML file in a browser. In fact, my files don't seem to give me that option. What I've done is named a text document index.html and nothing more. Any help would be appreciated. My operating system is windows 10.

Upvotes: 0

Views: 656

Answers (2)

Cadet
Cadet

Reputation: 366

Try this simple way:

<html>
    <head>

    </head>

    <body>
        <h1>Hello world</h1>
    </body>
</html>
  1. Copy-paste this content to the file and save it by name "index .html"
  2. Find this file, drag this with the mouse and drop it to the browser's URL field.
  3. Alternative way - enter the full path to the file in this format to browser's URL field: file:///full-path-to /index.html

It will open HTML page with the header "Hello World" at the top.

Upvotes: 1

Jos&#233; Marinho
Jos&#233; Marinho

Reputation: 53

I'm guessing you are using visual studio.

Inside the file you created (index.html), you can use emmet(a plugin that comes with vs) to set up your file correctly. Just type "!" in your empty HTML page and then press enter. Emmet will automatically fill all your file needs.

Then you will also need to run it on your local server. You have a tab on the left side of visual studio, go to extensions and look for "live server". Install it. When it's ready, on the bottom right of your VS you have a new option named "Go live", press it. If you don't see you can use the shortcut "Alt + L Alt + O"

If the browser doesn't open by itself after that, you can write down "localhost:{the number where it opened it}

Upvotes: 1

Related Questions