Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Elements

0/1

HTML Attributes

0/1

HTML Headings

0/1

HTML Paragraphs

0/1

HTML Styles

0/1

HTML Formatting

0/1

HTML Quotation

0/1

HTML Comments

0/1

HTML Colors

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Block and Inline

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML - The Head Element

0/1

HTML Style Guide

0/1

HTML Entities

0/1

HTML Symbols

0/1
Text lesson

HTML – The Head Element

The HTML <head> Element

The <head> element acts as a container for metadata, which encompasses information about the HTML document. Positioned between the <html> and <body> tags, metadata isn’t visible to users.

This metadata commonly includes defining the document title, character encoding, styles, scripts, and various other meta information.

The HTML <title> Element

The <title> element specifies the document’s title, which must consist solely of text and appears in the browser’s title bar or tab.

It’s imperative to include the <title> element in HTML documents.

The content of the page title holds significant importance for search engine optimization (SEO), as search engine algorithms utilize it to determine page rankings in search results.

The <title> element:

  • Defines a title in the browser toolbar.
  • Provides a title for the page when it’s bookmarked.
  • Displays a title for the page in search engine results.

Thus, it’s advisable to craft the title to be as precise and meaningful as possible.

Example of a simple HTML document:

Example

<!DOCTYPE html>
<html>
<head>
  <title>A Meaningful Page Title</title>
</head>
<body>

The content of the document……

</body>
</html>

The HTML <style> Element

The <style> element is employed to specify style information for an individual HTML page.

Example

<style>
  body {background-color: powderblue;}
  h1 {color: red;}
  p {color: blue;}
</style>

The HTML <link> Element

The <link> element establishes the connection between the current document and an external resource.

Typically, the <link> tag is utilized to reference external style sheets.

Example

<link rel=”stylesheet” href=”mystyle.css”>

The HTML <meta> Element

The <meta> element is commonly employed to define the character set, page description, keywords, authorship of the document, and viewport settings.

Although the metadata isn’t visible on the page, it is utilized by browsers to determine how to display content or refresh the page, by search engines to identify keywords, and by other web services.

Example

Specify the character encoding utilized:

<meta charset=”UTF-8″>

Specify keywords for search engine optimization:

<meta name=”keywords” content=”HTML, CSS, JavaScript”>

Provide a description of your webpage:

<meta name=”description” content=”Free Web tutorials”>

Specify the authorship of a page:

<meta name=”author” content=”John Doe”>

Refresh the document every 30 seconds:

<meta http-equiv=”refresh” content=”30″>

Configuring the viewport to ensure optimal display of your website across various devices:

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

Illustration of <meta> tags:

Example

<meta charset=”UTF-8″>
<meta name=”description” content=”Free Web tutorials”>
<meta name=”keywords” content=”HTML, CSS, JavaScript”>
<meta name=”author” content=”John Doe”>

Setting The Viewport

The viewport denotes the portion of a web page that is visible to the user. Its dimensions differ depending on the device, being smaller on a mobile phone compared to a computer screen.

It’s recommended to incorporate the following <meta> element into all your web pages:

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

This provides the browser with directives on managing the page’s dimensions and scaling.

The “width=device-width” segment adjusts the page’s width to match the device’s screen-width, which may vary depending on the device.

The “initial-scale=1.0” segment establishes the initial zoom level when the page is initially loaded by the browser.

Below is an illustration comparing a webpage without the viewport meta tag to the same webpage with the viewport meta tag:

Note: If you are accessing this page using a smartphone or tablet, you can tap on the two links below to observe the distinction.

The HTML <script> Element

The <script> element is employed to declare client-side JavaScripts.

The subsequent JavaScript code writes “Hello JavaScript!” into an HTML element identified by id=”demo”:

Example

<script>
function myFunction() {
  document.getElementById(“demo”).innerHTML = “Hello JavaScript!”;
}
</script>

The HTML <base> Element

The <base> element defines the base URL and/or target for all relative URLs within a page.

The <base> tag must contain either an href attribute, a target attribute, or both.

A document can contain only a single <base> element.

Example

Define a default URL and target for all links within a page:

<head>
<base href=”https://www.w3schools.com/” target=”_blank”>
</head>

<body>
<img src=”images/stickman.gif” width=”24″ height=”39″ alt=”Stickman”>
<a href=”tags/tag_base.asp”>HTML base Tag</a>
</body>

Summary of the Chapter

  • The <head> element serves as a repository for metadata, which provides information about the data within the document.
  • Positioned between the <html> and <body> tags, the <head> element is crucial.
  • The <title> element is obligatory, defining the document’s title.
  • For a single document, the <style> element is utilized to articulate style information.
  • Primarily, the <link> tag is employed to connect with external style sheets.
  • Typically, the <meta> element is used to designate the character set, page description, keywords, authorship of the document, and viewport settings.
  • To specify client-side JavaScripts, the <script> element is utilized.
  • The <base> element defines the base URL and/or target for all relative URLs within a page.