Let’s create a webpage using HTML, then view it in a web browser.
OK, lets get straight into it. Here, you will learn just how easy it is to create a web page. In fact, by the time you’ve finished with this web page, you will have created your own web page!
When you create a web page you will usually do something like this:
- Create an HTML file
- Type some HTML code
- View the result in your browser
- Repeat the last 2 steps (if necessary)
CREATE A WEBPAGE
OK, let’s walk through the above steps in more detail.
CREATE AN HTML FILE
An HTML file is simply a text file saved with an .html or .htm extension (i.e. as opposed to a .txt extension).
- Open up your HTML editor (such as Visual Studio Code or Sublime). You could use you computer’s normal plain text editor if you prefer (this will probably be Notepad if you’re using Windows or Text Edit if you’re using a Mac).
- Create a new file (if one wasn’t already created)
- Save the file as index.html
TYPE SOME HTML CODE
Type the following code:
<html> <head> <title>HTML Tutorial Example title> </head> <body> <h1>My First Website </h1> <p>Less than 5 minutes into this HTML tutorial and I've already created my first homepage!</p> </body> </html>
VIEW THE RESULT IN YOUR BROWSER
Navigate to the index.html file you created previously then double click on it
REPEAT THE LAST 2 STEPS UNTIL YOU’RE SATISFIED WITH THE RESULT
It’s unrealistic to expect that you will always get it right the first time around. Don’t worry that’s OK! Just try again and again until you get it right.
Part of the fun of creating web pages is experimenting with different elements, styles, approaches, etc, and then checking out the result.
EXPLANATION OF CODE
OK, before we get too carried away, I’ll explain what that code was all about.
We just coded a bunch of html tags.These tags tell the browser what to display and where. You may have noticed that for every “opening” tag there was also a “closing” tag, and that the content we wanted to display appeared in between. Most HTML tags have an opening and closing tag.
The next lesson goes into a bit more detail about HTML tags..