AsegGasiaBlog

HTML Part 2

HTML Basics

HTML Tags, Attributes & elements

Tags:

HTML tags are keywords (tag names) surrounded by angle brackets:

<tagname>content</tagname>
  • HTML tags normally come in pairs like <p> and </p>
  • The first tag in a pair is the start tag; the second tag is the end tag.
  • The end tag is written like the start tag, but with a slash before the tag name.


Attributes:

Tags can also have attributes, which are extra bits of information. Attributes appear inside the opening tag and their values sit inside quotation marks. They look something like:

<tag attribute="value">Margarine</tag>


Elements:

Elements are the bits that make up web pages.

Example 1:

<body> The quick brown fox jumps over the lazy dog. </body> 

everything that is in between (and includes) <body> and </body> tags is the body element.

Example 2:

<title>Rumple Stiltskin</title>

“<title>” and “</title>” are tags, “<title>Rumple Stiltskin</title>” is a title element


Below are the few essential HTML tags:

TagsDescription
<!DOCTYPE>This tag defines the document type and HTML version

<html>This tag encloses the complete HTML document and mainly comprises of document header which is represented by <head>...</head> and document body which is represented By <body>...</body> tags.
<head>

This tag represents the document's header which can keep other HTML tags like <title>, <link> etc.
<title>

The <title> tag is used inside the <head> tag to mention the Document title.
<body>
This tag represents the document's body which keeps other HTML tags like <h1>, <div>, <p> etc.
<!-- … -->
Defines a comment.


HTML Document structure

A typical HTML document will have following structure:


<!--Document declaration tag-->
<html>
    <head>
        Document header related tags
    </head>
    <body>
        Document body related tags
    </body>
</html>

Write HTML Using Notepad(Hello World)

1. Open Notepad.

2. Write HTML Code.
Copy and paste the following HTML code into your newly open text file.


<html>
    <head></head>
    <body>
        Hello world
    </body>
</html>

3. Save It.
Click File, save it with a HTML file extension, e.g. “helloworld.html”.

4. Demo.
Double click to view it. (Or open the newly saved HTML file with your favor Internet browser).


Explanation of code

  • <html></html> tag is tell internet browser this file is a start and end of the HTML file document.
  • Text between <head></head> tag is for HTML header information, which is not display in internet browser.
  • Text between <title></title> will display in left-up corner in internet browser, its web page title.
  • Text between <body></body> will display as content in internet browser.

Popular Posts