HTML (Hypertext Markup Language) is the standard language used to create and structure content on the web. It provides the foundational structure of a webpage by defining elements such as headings, paragraphs, links, images, tables, and more. HTML is used to describe the content and its structure on a webpage, which is then interpreted by web browsers to display the content in a user-friendly way.
Elements and Tags:
< >
).
Tags usually come in pairs: an opening tag and a closing tag, like <p>
and </p>
. Some tags are self-closing,
like <img />
.
Example:
<h1> This is a heading </ h1>
<p> This is a paragraph. </ p>
Attributes:
Example:
<a href="https://www.example.com">Visit Example </a>
<img src="image.jpg" alt="An image description" />
Document Structure:
<!DOCTYPE>
declaration, an <html>
root element,
and two main sections: <head>
and <body>
.
Example:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Web Page</title>
</head>
<body>
<h1>Welcome to My Web Page</h1>
<p>This is where the content goes.</p>
</body>
</html>
<!DOCTYPE html>:
<!DOCTYPE>
declaration defines the document type and version of HTML. For modern HTML documents, <!DOCTYPE html>
is used, which refers to HTML5.<html> Element:
<html>
element is the root element of an HTML document. It encloses all the content on the webpage.<head> Element:
<head>
element contains metadata about the document, such as the title, character set, linked stylesheets, and scripts. This information is not directly displayed on the page.Common Elements in the Head:
<title>
: Sets the title of the webpage, shown in the browser tab.<meta charset="UTF-8">
: Defines the character encoding.<meta name="viewport" content="width=device-width, initial-scale=1.0">
: Ensures the webpage is responsive, adapting to different devices.<link rel="stylesheet" href="styles.css">
: Links to an external CSS file for styling.<script src="script.js"></script>
: Links to an external JavaScript file.<body> Element:
<body>
element contains all the content that is displayed on the webpage, such as text, images, videos, and links.Common Elements in the Body:
<h1>
to <h6>
tags are used to create headings, with <h1>
being the most important and <h6>
the least.<p>
tags are used to define paragraphs.<a>
tags are used to create hyperlinks.<img>
tags are used to embed images.<ul>
(unordered list), <ol>
(ordered list), and <li>
(list item) tags are used to create lists.<table>
, <tr>
(table row), <th>
(table header), and <td>
(table data) tags are used to create tables.<form>
, <input>
, <textarea>
, <button>
, and other tags are used to create forms for user input.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple HTML Example</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a simple HTML document.</p>
<a href="https://www.example.com">Visit Example</a>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
<img src="image.jpg" alt="An example image">
</body>
</html>
There are two types of markup and hence there exists two types of markup languages. They are procedural and generalized.
- Procedural markup is typified by its use in typesetting and publishing systems, including word processors.
There is a major shortcoming in the procedural markup languages. That is, if we intend to extract information from the documents, procedural markup language is found wanting. To meet this challenge, a generalized markup language marks up documents in a different way. The characteristics of these languages are:
1. The elements have logical names, rather than expressing detailed formatting instructions. For example, an element H1 is being used to mark up text that is intended to be a first-level header.
2. Software applications that read documents marked up using a GML are free to present them as they see fit, using formatting rules for particular elements that are either defined internally, or specified elsewhere. When displayed in the screen, the H1 element could be associated with a particular combination of font size and weight.
GML elements usually involve both start and end tags so that the original content is fully contained inside an element. Also there is no hint about how this document should be presented. That is, the web browsers are free to reflect the meanings of these elements. The most commonly used generalized markup language is HTML for web documents and WML for mobile contents.
Generalized Markup Rule-sets Each GML has its own elements, its own rules, and its own particular area of application and in order for the language to function properly as a language, those must all somehow be defined. GMLs are themselves written using Generalized Markup Rule-sets (GMRS), also called meta-languages. The two famous meta-languages are Standard Generalized Markup Language (SGML) and the Extensible Markup Language (XML). In a way, XML is a subset of SGML and WML is derived from XML.
Recently another markup language called as Extensible HTML (XHTML) for future web publishing came out. XHTML is a reformulation of HTML 4 in XML. XHTML has to be designed to avoid some undesirable features of HTML.
Though all these features can be accomplished easily using XML, XHTML has been formulated for keeping the large investment made in HTML.
Below is the list of markup languages :-
CSS (Cascading Style Sheets):
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
h1 {
color: #333;
}
</style>
JavaScript:
JavaScript is a scripting language used to create dynamic content on a webpage. It can be used to manipulate the DOM (Document Object Model), handle events, validate forms, and much more.Example:
<script>
function showMessage() {
alert('Hello, World!');
}
</script>
<button onclick="showMessage()">Click Me</button>
HTML is the essential language of the web, defining the structure and content of web pages. It works in harmony with CSS and JavaScript to create visually appealing and interactive websites. Understanding HTML is fundamental to web development, as it forms the base upon which all other web technologies are built.