HTML
- HTML is the standard markup language for creating web pages.
- HTML stands for Hyper Text Markup Language.
- HTML describes the structure of a web page.
- HTML consists of a series of elements.
- HTML elements tell the browser how to display the content.
- HTML elements are represented by tags.
- HTML tags label pieces of content such as "heading", "paragraph", "table", and so on.
- Browsers do not display the HTML tags, but use them to render the content of the page.
Tag
In information systems, a tag is a keyword or term assigned to a piece of information. This kind of metadata helps describe an item and allows it to be found again by browsing or searching.
Basic Tags of HTML
-
HTML tags are element
Basic Tags of HTML
- HTML tags are element names surrounded by angle brackets:
- 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 forward slash inserted before the tag name
- The <!DOCTYPE html> declaration defines this document to be HTML5
- The <html> element is the root element of an HTML page
- The <head> element contains meta information about the document
- The <title> element specifies a title for the document
- The <body> element contains the visible page content
- The <h1> element defines a large heading
- The <p> element defines a paragraph
Who invented HTML language?
In 1991 Tim Berners-Lee invented HTML.
HTML text Editors
- An HTML file is a text file, so to create an HTML file we can use any text editors.
- Text editors are the programs which allow editing in a written text, hence to create a web page we need to write our code in some text editor.
- There are various types of text editors available which you can directly download, but for a beginner, the best text editor is Notepad (Windows) or TextEdit (Mac).
- After learning the basics, you can easily use other professional text editors which are, Notepad++, Sublime Text, Vim,VSCode etc.
HTML Page Structure
<html> tag is the root element of an HTML page, which contains head and body elements.
Head element contains meta information about the document like title, style, and scripts.
Body element contains the visible page content like text, images, videos, etc.
HTML Tags
HTML tags are like keywords which define that how web browser will format and display the
content. With the help of tags, a web browser can distinguish between an HTML content and a
simple content. HTML tags contain three main parts: opening tag, content,
and closing tag. But some HTML tags are unclosed tags.
An HTML file must have some essential tags so that web browser can differentiate between a
simple text and HTML text. You can use as many tags you want as per your code requirement.
All HTML tags must be enclosed within <> these brackets.
Every tag in HTML performs different tasks.
If you have used an open tag <tag>, then you must use a close tag </tag>
(except some tags)
HTML tags are used to create web pages and define the structure, content, and presentation of the web pages. Here is a brief description of each tag you have mentioned: <!-...->: It is a comment tag that is used to write comments in the HTML code. The comments are not displayed on the webpage.
- <!DOCTYPE >: It specifies the version of HTML that is being used in the document..
- <code >: It is used to indicate computer code or programming language..
- <col >: It is used to define a single column within a table..
- <style >: It is used to define the style of the HTML elements..
- <sub >: It is used to display the text in subscript, which is usually smaller and below the baseline..
- <a >: It is used to create a hyperlink that can be clicked to navigate to another webpage or to a different location on the same webpage..
- <summary >: It is used to define a summary or caption for the content of a webpage..
- <frameset >: It is used to divide a webpage into multiple frames..
- <object >: It is used to embed multimedia content, such as videos or audio, into a webpage..
- <h1 > to
- <h6 >: They are used to create headings of different sizes and levels..
- <ol >: It is used to create an ordered list of items..
- <head >: It is used to define the header section of a webpage, which includes the title, meta tags, and links to external files..
- <optgroup >: It is used to group related options within a drop-down list..
- <header >: It is used to define the header section of a webpage, which typically includes the logo and navigation links..
- <option >: It is used to define an option within a drop-down list..
- <hr >: It is used to create a horizontal line that separates content on a webpage..
- <output >: It is used to display the result of a calculation or user action on a webpage..
- <html >: It is the root element of an HTML document..
- <abbr >: It is used to indicate an abbreviated form of a word or phrase..
- <sup >: It is used to display the text in superscript, which is usually smaller and above the baseline..
- <colgroup >: It is used to define a group of columns within a table..
- <data >: It is used to define a value that can be used for calculations or other purposes..
- <acronym >: It is used to indicate an acronym or abbreviation.
- <address >: It is used to display the contact information for the author or owner of a webpage..
- <svg >: It is used to display vector graphics on a webpage..
- <table >: It is used to create a table on a webpage..
- <tbody >: It is used to group the body content of a table..
- <datalist >: It is used to create a list of predefined options for an input field..
- <p >: It is used to define a paragraph of text..
- <applet >: It is used to embed Java applets into a webpage..
- <dd >: It is used to define a description for an item within a definition list..
- <i >: It is used to indicate a phrase in italicized text..
- <td >: It is used to define a cell within a table..
- <param >: It is used to pass parameters to an embedded object.
- <pre >: This tag is used to preserve white spaces and line breaks. It is commonly used for displaying code snippets or text that needs to be formatted in a specific way..
- <progress >: This tag is used to represent the progress of a task. It can be used to show a progress bar or other visual indicators of progress..
- <template >: This tag is used to define reusable content that can be used throughout a web page. It is commonly used for creating templates for dynamic content..
- <textarea >: This tag is used to create a text input field where users can input multiple lines of text..
- <q >: This tag is used to define a short quotation. The text inside the tag is displayed with quotation marks around it..
- <tfoot >: This tag is used to define a table footer. It is used to display summary information about the table..
- <th >: This tag is used to define a table header cell. It is used to label the contents of a table cell..
- <rp >: This tag is used to define what to display if a browser does not support ruby annotations. It is commonly used in Asian typography..
- <cite >: It is used to indicate the title of a work, such as a book or a movie.
- <rt >: This tag is used to define the pronunciation of a ruby annotation. It is commonly used in Asian typography..
- <thead >: This tag is used to define a table header. It is used to group the header content in a table..
- <ruby >: This tag is used to define ruby annotations. It is commonly used in Asian typography..
- <time >: This tag is used to define a date or time. It can be used to display dates or times in a specific format..
- <S >: This tag is used to define strikethrough text. The text inside the tag is displayed with a line through it..
- <title >: This tag is used to define the title of a web page. It is displayed in the browser 's title bar..
- <area >: This tag is used to define an area within an image map. It is used to create clickable areas within an image..
- <del >: This tag is used to define deleted text. The text inside the tag is displayed with a line through it..
- <iframe >: This tag is used to embed another web page or content within a web page. It is commonly used for displaying videos or other media..
- <article >: This tag is used to define an article or section of content within a web page. It is used to group related content together..
- <details >: This tag is used to create a collapsible section of content. It is used to hide content that is not immediately relevant..
- <img >: This tag is used to display an image on a web page. It can be used to display images of various formats..
- <aside >: This tag is used to define a section of content that is related to the main content of the web page, but not essential to it..
- <dfn >: This tag is used to define a term. It is commonly used in glossaries or dictionaries..
- <input >: This tag is used to create a form input field. It can be used to create various types of input fields such as text fields, checkboxes, radio buttons, and more..
- <audio >: This tag is used to embed an audio file within a web page. It is commonly used for playing music or other audio content..
- <dialog >: This tag is used to create a dialog box or popup window. It can be used for displaying important information or for getting user input
- <ins >: This tag is used to indicate text that has been inserted into a document..
- <kbd >: This tag is used to define keyboard input, and it is often used to display shortcuts and commands..
- <b >: This tag is used to make text bold..
- <dir >: This tag is used to define a directory list..
- <base >: This tag is used to specify a default URL and a default target for all links on a page..
- <div >: This tag is used to create a container for other HTML elements..
- <label >: This tag is used to associate a label with a form control..
- <basefont >: This tag is used to specify the base font size, color, and face for a page..
- <dl >: This tag is used to define a description list..
- <legend >: This tag is used to define a caption for a fieldset element..
- <bdi >: This tag is used to define text that should be isolated from its surrounding text in order to be formatted in a different direction..
- <dt >: This tag is used to define a term in a description list..
- <li >: This tag is used to define a list item..
- <bdo >: This tag is used to override the default direction of text..
- <em >: This tag is used to make text emphasized..
- <link >: This tag is used to link to an external resource, such as a stylesheet or a script..
- <big >: This tag is used to make text larger..
- <embed >: This tag is used to embed multimedia content, such as audio or video..
- <main >: This tag is used to indicate the main content of a page..
- <blockquote >: This tag is used to indicate a long quotation..
- <fieldset >: This tag is used to group related form controls..
- <map >: This tag is used to define an image map..
- <body >: This tag is used to define the body of an HTML document..
- <figcaption >: This tag is used to define a caption for a figure element..
- <mark >: This tag is used to highlight text..
- <br >: This tag is used to insert a line break..
- <figure >: This tag is used to group related content, such as images and captions..
- <meta >: This tag is used to specify metadata for a document, such as keywords and description..
- <small >: This tag is used to make text smaller..
- <button >: This tag is used to define a clickable button..
- <font >: This tag is used to define font size, color, and face..
- <meter >: This tag is used to define a scalar measurement within a known range..
- <canvas >: This tag is used to draw graphics and animations on a web page..
- <footer >: This tag is used to define the footer of a document or a section..
- <nav >: This tag is used to define a section of navigation links..
- <caption >: This tag is used to define a caption for a table..
- <form >: This tag is used to define a form..
- <noframes >: This tag is used to define content that should be displayed if a browser does not support frames..
- <noscript >: This tag is used to define content that should be displayed if a browser does not support scripting..
- <center >: This tag is used to center text or other content..
- <frame >: This tag is used to define a frame within a frameset..
- <tr >: This tag is used to define a table row..
- <samp >: This tag is used to define sample output from a computer program..
- <script >: This tag is used to define client-side scripts, such as JavaScript.
- <section >: It represents a section of a document, usually with a heading. It is used to group related content together and can be used for outlining purposes..
- <track >: It is used to provide timed text tracks, such as captions or subtitles, for media elements like video and audio..
- <tt >: It is used to indicate text that should be rendered in a monospace font like a typewriter. It was commonly used in the past to display code snippets, but it is now recommended to use the.
- <code > tag instead..
- <select >: It is used to create a dropdown list of options for users to choose from. It can be used for a variety of purposes, such as selecting a date or choosing a product from a list..
- <u >: It is used to underline text, but it is generally not recommended for styling purposes because it can be difficult to distinguish from hyperlinks..
- <ul >: It is used to create an unordered list of items, typically with bullet points. Each item is enclosed in a.
- <li > tag.
- <source >: It is used to specify the source of media content like video or audio. Multiple source tags can be used within a single media element to provide different formats or quality levels for different devices..
- <var >: It is used to indicate a variable in a computer program or a mathematical equation. It can also be used to indicate a placeholder or a variable term in a natural language text..
- <video >: It is used to embed video content in a web page. It supports a wide range of video formats and provides various playback controls and options..
- <span >: It is used to group inline elements together and apply styles to them. It can also be used for scripting purposes..
- <strike >: It is used to indicate text that has been struck through, usually to indicate that it has been deleted or is no longer valid. However, it is now recommended to use the.
- <del > tag instead..
- <wbr >: It is used to indicate a word break opportunity, which allows a long word to be broken into multiple lines if necessary. It is particularly useful for languages that do not use spaces between words..
- <strong >: It is used to indicate strong emphasis on text, typically by making it bold. However, it should not be used solely for visual formatting and should have semantic meaning in the context of the content.
HTML Headings
HTML headings are defined with the <h1> to <h6> tags. <h1> defines the most important heading. <h6> defines the least important heading
Example:
<!DOCTYPE html>
<html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
output
This is heading 1
This is heading 2
This is heading 3
This is heading 4
This is heading 5
This is heading 6
HTML Paragraphs - HTML paragraphs are defined with the
Example:
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
HTML Elements:
- An HTML element is defined by a start tag, some content, and an end tag.
- Examples of some HTML elements:
-
<h1>My First Heading</h1>
-
<p>My first paragraph.</p>
Nested HTML Elements:
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Empty HTML Elements:
- HTML elements with no content are called empty elements.
-
The
<br>
tag defines a line break, and is an empty element without a closing tag.
Example:
<p>This is a <br> paragraph with a line break.</p>
HTML Attributes:
- HTML attributes provide additional information about HTML elements.
- Attributes are defined in the start tag.
- All HTML elements can have attributes
- Attributes provide additional information about elements
- Attributes are always specified in the start tag
- Attributes usually come in name/value pairs like: name="value"
Syntax:
<element attribute_name="value">content</element>
1. href Attribute
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>The href Attribute </h2>
<p>HTML links are defined with the a tag.
The link address is specified in the href attribute:>
</body>
</html>
2. The src Attribute
The sre attribute is one of the important and required attributes of <img> element for the image which is required to display on the browser.
Example:
<!DOCTYPE html>
<html> <head>
</head>
<body>
<h1>Example of src attribute</h1>
<p>HTML images can be displayed with the help of the
image tag and its attribute src gives
the source for that image</p>
<img src="https://github.io/
</body>
</html>
3. style Attribute
The style attribute is used to add styles to an element, such as color, font, size, and more. <p style="color:red;">This is a red paragraph.</p>
Example:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p style="color:red;">
This is a red paragraph.</p>
</body>
</html>