HTML Basic Examples
HTML, which stands for HyperText Markup Language, is the standard language used to create and structure content on the web. It consists of a set of elements, each represented by tags, which are used to define the structure and appearance of a web page. Here's a basic overview of HTML:
-
HTML Document Structure: An HTML document starts with a declaration and consists of the following main parts:
Example
<!DOCTYPE html><!-- Declaration -->
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html> Head Section: The
<head>section contains meta-information about the document and links to external resources. The<title>tag sets the title displayed in the browser's title bar or tab.Body Section: The
<body>section contains the visible content of the web page.Text and Headings: Use headings from
<h1>to<h6>for various levels of headings and the<p>tag for paragraphs.Example
<h1> Main Heading</h1>
<p> This is a paragraph of text.> </p>Links: The
<a>tag is used to create hyperlinks.Example
<a> https://www.example.com </a>Images: The
<img>tag is used to display images.Example
<src src="image.jpg" alt="image of alt">Lists: Use
<ul>for an unordered list and<ol>for an ordered list. List items are created with<li>.Example
<ul>
<li> Item 1 </li>
<li> Item 2 </li>
</ul>Forms: Forms are created using the
<form>tag and contain input elements like text fields, radio buttons, checkboxes, etc.Example
<form action="submit.php" method="post">
<input type="text" name="username" placeholder="Username">
<input type="password" name="password" placeholder="Password">
<input type="submit" value="Submit">
</form>Comments: Comments can be added to the code using
<!-- comment text -->.Basic Formatting: For basic text formatting, you can use the
<strong>tag for bold and<em>tag for italic.Example
<p> This is<strong>bold</strong> and this is <em> italic</em>text.</p>
