Exercise
Follow the steps above so that you are left with the same code outlined at the end of the section. Save the file you created (index.html) and open it in your web browser (usually file > open in the menu). You should notice how the web browser returns a blank page. This is because tags are only ever interpreted by the web browser, never displayed. Try typing some text between the body tags – notice how the webpage displays the text you typed and nothing else. This is the principle on which websites are displayed. Learning how the browser handles tags, and understanding that these tags are merely instructions to the browser, telling it what type of content sits inside, is fundamental to your learning of HTML. By understanding this principle, you have mastered the first and most fundamentally important step in learning how to write efficient and semantic HTML code.
Table 2.2 Text glossary
Semantic |
Giving meaning to information in order to allow a computer to interpret it successfully |
HTML header tags are used to tell the browser where our headers are situated. They tell the browser which text is more important, and how important it is. Header tags are very simple to write; they are defined using <h1> through to <h6> tags, h1 being the most important level of header text, and h6 being the least important header text. Let’s explore this further by writing some code.
In between your <body> tags, copy and paste the following text:
This is a header
This is a subheader
Save your file and open it in your browser. Notice how it all appears together in one big chunk? This is because we haven’t told the browser how our content is broken up. Now copy the code below into your file and refresh your webpage.