- 2.4 Basic Tags In a Webpage
- <!DOCTYPE html>
- Previous Section
- Next Section
2.4 Basic Tags In a Webpage
So what HTML tags do you need to have to create the most basic, bare-bones website? Let's look at this example to find out.
<!DOCTYPE html> <html> <head lang="en"> <title>Basic Tags</title> <meta charset="utf-8"> </head> <body> <p>This is some paragraph text</p> </body> </html>
Output of the above code:
This is some paragraph text
On line 1 we see that the DOCTYPE tag. This tells the browser that the document is reading in an HTML document. This should always go at the top of the document.
On lines 3 and 6 are the start and end head tags. It is used as a container element to store metadata (information about the website) that is put in between the HTML and body tags. You should always specify the value for the language attribute for the head tag. The value should be the correct language code. The code for English is "en". Here is a reference for language codes:
HTML Language Code Reference
You should always include the attribute inside the tag, to declare the language of the Web page. This is meant to assist search engines and browsers: In XHTML, the language is declared inside the tag as follows: ISO 639-1 defines abbreviations for languages: See also: Reference for Country Codes.
On line 4 is the title tag. The content of inside of this tag is what displays as the site title(the text displayed on the tab of your web browser.)
Online 5 is the meta tag, which is where you put metadata about the webpage. It's usually good practice to have at least 1 meta ta which provides a value for the charset(character set) attribute, which is typically UTF-8. UTF-8 is a character encoding scheme. You can read more about it here:
Character encodings for beginners
Intended audience: content authors, users, and anyone who is unsure about what a character encoding is, and wants a brief summary of how it affects them. What is a character encoding, and why should I care?
On line 7 and 9, you can see the body tags. All of the content that appears on the website goes in this tag.
On line 8, you can see the p (paragraph) tags. This tells the browser that the content inside the tag is paragraph text.