Putting a title at the top of a web page is always a good idea in order to quickly inform the user what the page is about or what the name of the website is, just like a chapter title in a book or a flavour label on a cat food sachet.
For this, we use a heading element by including a heading tag in HTML. Even though the name is similar, this code doesn’t go in the head tag; remember the stuff we want to show goes inside the body tag.
A heading tag is written just like the tags we wrote earlier but instead of breakfast, snack or munchies, which aren’t real tags, we use h1 instead so the complete heading tag code looks like this.
<h1> </h1>
And it goes in the body tag like this:
<body>
<h1> </h1>
</body>
The content between the opening and closing parts of the body tag tells the computer what to show and this code tells the computer to show some large, bold text suitable for a title. The words between the opening h1 and the closing h1 tells the computer what text to add for your title.
Try to write your own. Here is an example I wrote:
<body>
<h1>Hello World!</h1>
</body>
Here's the title that the code produces:
Alternatively, here are some examples written by Aria:
<body>
<h1>I Am The Best!</h1>
</body>
<body>
<h1>Give Me Food And Tummy Rubs!</h1>
</body>
Now my titles have been added, it’s time for me to start adding my proper content.
Yes, we are almost ready to start adding something more informative onto your page.
What I have to say is very important so I think I’m just going to write it all in a h1 tag.
That way no one will miss it.
That’s not such a great idea.
If you do that how will anyone spot what the real title is?
Your page will be difficult to read and understand.
There are other options for when you want to highlight something or include additional headings.
Then I can write all about places to doze?
Of course!
And why dogs are bad.
Fine, if you want.
And what furniture I like to scratch.
You’re not still doing that are you?
On The List Of Favourite Places To Doze
Try writing your own by adapting the code below:
If you have copied one of the h1 tag examples or written your own, you can view the result by saving your HTML file, finding it on your computer and opening the file, which is usually done by clicking on it twice. When you do this, your computer will use the browser to read and display your HTML files.
As the HTML file is on your computer, and not on a server which anyone can access, only you, or people with access to your computer can see it. At this stage that’s just fine; let’s add some more content before we share it with everybody else.
You’ve just finished your first proper HTML code which will display something! Go ahead and look at the result!