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 name a text document index.html and nothing more. Any help would be appreciated.
also am on windows 10.
CodePudding user response:
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}
CodePudding user response:
Try this simple way:
<html>
<head>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
- Copy-paste this content to the file and save it by name "index .html"
- Find this file, drag this with the mouse and drop it to the browser's URL field.
- 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.
