HTML Basic Syntax

HTML Basic Syntax - Learn HTML

HTML Basic Syntax

HTML (Hypertext Markup Language) is the standard language used to create webpages. Understanding its basic syntax is essential for building webpages. Below are the key components of HTML syntax:

1. HTML Elements

An HTML element consists of a start tag, content, and an end tag. The content goes between the tags. The basic structure of an HTML element looks like this:

<tagname>Content</tagname>

For example:

<p>This is a paragraph.</p>

2. HTML Tags

HTML tags are keywords surrounded by angle brackets (< and >). They come in pairs: an opening tag and a closing tag. The closing tag has a forward slash before the tag name.

<h1>This is a heading</h1>

3. HTML Attributes

Attributes provide additional information about an element. They are always included in the opening tag and consist of a name and a value:

<tagname attribute="value">Content</tagname>

For example, the href attribute in a link:

<a href="https://www.example.com">Visit Example</a>

4. HTML Document Structure

An HTML document has a specific structure. It starts with the <!DOCTYPE html> declaration, followed by the <html> element, which contains the <head> and <body> elements:


<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
    <p>This is a paragraph.</p>
  </body>
</html>
        

Try It

5. Void Elements

Void elements do not have content or a closing tag. Examples include <br> for line breaks and <img> for images. For example:

<img src="image.jpg" alt="Description">

6. Comments

HTML comments are used to insert notes in the code that will not be displayed in the browser. They are written like this

Post a Comment

0 Comments

Get in Touch   Subscibe
Update cookies preferences