Search This Blog

Tuesday, November 14, 2017

HTML Tutorial Part 2 : Headings And Anchor

Hi everyone, in this tutorial we going to cover 2 more important tag in HTML. Once we're done with this, you should be ready to create your website and we will be starting our CSS tutorial to make our website looks better. Of course HTML has far more tag than this but we will leave all those complicated things for later as they are not really useful for us (at least for now).

The first tag we going to talk about is heading tag. Basically heading tag is use tell browser "this is a heading so display it in a large size".There are 6 different font size you can choose for your heading by using <h1> to <h6> tag with <h1> being the largest and <h6> is the smallest. As always, each tag needs an open and closing tag so make sure you pair each of your <h1> <h2> .... tag with </h1> </h2> .... tag. To show how it works, open the HTML file we created in the previous in your text editor and edit it as follow,

Codes to create heading

Notice how I only use <h1> and <h2> here. Normally, we only use <h1> up to <h3> in a website because your website will looks really weird if you have like 6 different size of heading there. Also, if you notice, I also make an indent before each tag I put between the <body> tag. It is not required to make the indent but it is a good practice to do them as it will make your HTML file cleaner and easier to read. This way, your will know which tag is inside which with just a glance. Once you're done editing, save your file and refresh your browser. you should see something like this in your browser.

Displaying results of HTML heading tag in browser
There are now 3 different size of text with the largest being the text enclosed in <h1> tag followed by the one in <h2> tag followed by <p> tag. Now that you know how to make a heading, lets talk about anchor tag.

Anchor tag is used to make a link to a certain place but unlike other tag, anchor tag has an attribute and value which specify where the link is connected to. For example,

Codes to create anchor tag or link in HTML


The <a> is the anchor tag and it is followed by a closing tag. Anything in between the opening and closing off anchor tag is what you want to make into a link, it can be a text or even image. In this case, we make the word 'tutorial' into a link. Notice there is an extra text in the <a> tag. the href is an attribute which is the hyperlink reference. It means that any value given to this attribute is the target of the link. The url in the quotation mark is the value of the attribute which means it is the target of the link. Note that quotation mark is always needed to give value to an attribute. 

Now lets save the file and refresh your browser, you should get something like this,

Displaying results of HTML anchor tag in browser

The word 'tutorial' had become a link and if you click it, it should sent you to the url we put in the anchor tag earlier. The underline and colour for the word 'tutorial' is the default style for links, we will learn how to change them later in CSS tutorial.

If you got any question about what we've learnt so far, feel free to ask in the comment below. see you in the next tutorial.


No comments:

Post a Comment