HTML
HTML (HyperText Markup Language) is used to give content to a web page and instructs web browsers on how to structure that content.
HTML Tags
HTML element (or simply, element) — a unit of content in an HTML document formed by HTML tags and the text or media it contains. HTML Tag — the element name, surrounded by an opening (<) and closing (>) angle bracket.
<h1> My First Heading <h1>
HTML Structure
HTML is organized as a collection of family tree relationships. As you saw in the last exercise, we placed <h1> tags within <body> tags. When an element is contained inside another element, it is considered the child of that element. The child element is said to be nested inside of the parent element.
<body>
<h1> This header is a child of the body <h1>
</body>
HTML Page Tag Group
The Page Tag Group is a group of tags that are used to define the structure of a web page. All web pages require a well-defined page structure with a handful of foundational tags. This structure allows browsers to correctly process and render the pages.
Tag | Name | Description |
---|---|---|
<!DOCTYPE html> | Document Type Declaration | The document type declaration <!DOCTYPE html> is required as the rst line of an HTML document. The doctype declaration is an instruction to the browser about what type of document to expect and which version of HTML is being used, in this case it's HTML5. |
<html> | HTML | The <html> element, the root of an HTML document, should be added after the !DOCTYPE declaration. All content/structure for an HTML document should be contained between the opening and closing <html> tags |
<head> | Head | The <head> element contains general information about an HTML page that is not displayed on the page itself. This information is called metadata and includes things like the title of the HTML document and links to stylesheets |
<meta> | Metadata | The <meta> tag defines metadata about an HTML document. Metadata is data (information) about data. <meta> tags always go inside the <head> element, and are typically Metadata will not be displayed on the page, but is machine parsable. |
<link> | link Tag | The <link> tag loads a linked resource into a page. This tag is used to include a stylesheet or a favicon into a page. Links are placed in the <head> section of the page. |
<title> | Title | The <title> element contains a text that de nes the title of an HTML document. The title is displayed in the browser's title bar or tab in which the HTML page is displayed. The <title> element can only be contained inside a document's element |
<body> | Body | The <body> element represents the content of an HTML document. Content inside <body> tags are rendered on the web browsers. There can be only one <body> element in a document. |
<!--...--> | Comments | In HTML, comments can be added between an opening <!-- and closing -->. Content inside of comments will not be rendered by browsers. Comments can span single or multiple lines. |
Layout Tag Group
The Layout Tag Group is a group of tags that define document layouts. Most web pages require a layout with headers, columns, footers, and other sections. This is similare to how a magazine or a newspaper page is organized. Layout tags define areas on a page that contain content. Layout tags define areas on a page that contain content. By default these tags have no visual appearance, but they are often styled with a border or background color
Tag | Name | Description |
---|---|---|
<header> | Header | The <header> element represents a container for introductory content or a set of navigational links. A <header> element typically contains one or more heading elements (<h1> - <h6>), logo or icon or authorship information |
<main> | Main | The <main> tag specifies the main content of a document. The content inside the <main> element should be unique to the document. It should not contain any content that is repeated across documents such as sidebars, navigation links, copyright information, site logos, and search forms. |
<footer> | Footer | The <footer> tag defines a footer for a document or section. |
<nav> | Navigation tag | The <nav> tag creates a container for navigation elements. It can hold navigation menus, quicklinks, table of contents, etc. |
<aside> | Aside content | The <aside> tag defines some content aside from the content it is placed in. The aside content should be indirectly related to the surrounding content. |
<article> | Article | The <article> tag specifies independent, self-contained content. An article should make sense on its own and it should be possible to distribute it independently from the rest of the site. It's used for blog posts, forums, newspaper articles, and more. E-commerce articles include product descriptions, product cards, etc. |
<section> | Section | The <section> tag defines a section in a document. The <section> element contains stand-alone text or content. Of all semantic tags, <section> is the closest to a <div>. |
<div> | Division | <div>s short for “division” or a container that divides the page into sections. |
Table Tag Group
The Table Tag Group is a group of tags that are used to create HTML tables. HTML tables present tabular data.
Tag | Name | Description |
---|---|---|
<table> | Tabular display of data | The <table> tag creates an HTML table. A table is a tabular display of data, arranged in rows and columns. Tables are highly configurable with captions, headers, footers, column and row spans, and more. |
<thead> | Header of the table | The <thead> element is used in conjunction with the <tbody> and <tfoot> elements to specify each part of a table (header, body, footer). |
<tbody> | Table body content | The <tbody> tag is used to group the body content in an HTML table. The <tbody> element is used in conjunction with the <thead> and <tfoot> elements to specify each part of a table (body, header, footer). |
<tfoot> | Table footer content | The <tfoot> tag is used to group footer content in an HTML table. The <tfoot> element is used in conjunction with the <thead> and <tbody> elements to specify each part of a table (footer, header, body). |
<tr> | Table row | The <tr> tag creates a table row in an HTML table. Each row is a container for one or more table cells. A table can have any number of rows. |
<th> | Table header cell | The <th> tag adds a table header cell to an HTML table. Each table header cell contains a title that describes the data in the cells below. |
<td> | Table data cell | The <td> tag adds a table cell to an HTML table. A table cell is a boxed area that displays a single data item |
Text Tag Group
The Text Tag Group is a group of tags that are used to create well-formatted text documents. Tip: More recently, text formatting and styling has shifted from HTML to CSS.
Tag | Name | Description |
---|---|---|
<h1>...<h6> | Headings | Headings in HTML are similar to headings in other types of media. |
<p> | Paragraph | A paragraph is a distinct section of text with spacing before and after. |
<span> | Span | The <span> tag is an inline container used to mark up a part of a text, or a part of a document. |
<br> | Line Breaks | The <br> tag in HTML document is used to create a line break in a text. |
<em> | Emphasis Element | The <em> tag will generally render as italic emphasis. |
<strong> | Bold text style | The <strong> will generally render as bold emphasis. |
List Tag Group
The List Tag Group is a group of tags that are used to define lists of data items. A list is a sequential display of related items. HTML supports 3 list types: unordered lists, ordered lists, and datalists. Each of these list types have their own tags.
Tag | Name | Description |
---|---|---|
<ul> | Unordered Lists | An unordered list outlines individual list items with a bullet point. |
<ol> | Ordered Lists | Ordered lists are like unordered lists (<ul>), except that each list item is numbered. |
<li> | List | The <li> tag defines a list item. The <li> tag is used inside ordered lists(<ol>), unordered lists (<ul>). |
Media Tag Group
The Media Tag Group is a group of tags that help with creating multi-media experiences on a web page. With increasing bandwidths, multi-media is becoming very important in web development. These include: images, animations, audio, and video.
Tag | Name | Description |
---|---|---|
<audio> | Audio | The <audio> element creates a player for sound such as music, sound effects, or others. |
<video> | Video | The <video> element embeds a media player for video playback. The src attribute will contain the URL to the video. Adding the controls attribute will display video controls in the media player. |
<img> | Image | HTML image <img> elements embed images in documents. The src attribute contains the image URL and is mandatory. <img> is an empty element meaning it should not have a closing tag. |
<figure> | Figure - embedded object | The <figure> tag creates a container that can embed any of the following: Images, Illustrations, Infographics, Code Snippets, and others |
<figcaption> | Figure caption | The <figcaption> tag adds a description to a <figure>. Figure captions summarize or describe the figure or image. |
HTML Attributes
Attributes provide features or functionality to an element. Attributes are placed inside the element's opening tag. An element can have any number of attributes.
<p id="my-paragraph" class="black" style= "color: black;"> This example is a paragraph with 3 attributes: id, class, and style. </p>
Tag | Name | Description |
---|---|---|
id | Unique ID Attributes | In HTML, specific and unique id attributes can be assigned to different elements in order to differentiate between them. When needed, the id value can be called upon by CSS and JavaScript to manipulate, format, and perform specific instructions on that element and that element only. Valid id attributes should begin with a letter and should only contain letters ( a - Z ), digits ( 0 - 9 ), hyphens ( - ), underscores ( _ ), and periods ( . ). |
alt | alt Attribute | An <img> element can have alternative text via the alt attribute. The alternative text will be displayed if an image fails to render due to an incorrect URL, if the image format is not supported by the browser, if the image is blocked from being displayed, or if the image has not been received from the URL. |
href | href Attribute | The href attribute defines a link address for an a tag. |
target | Target Attribute | The target attribute on an <a> anchor element speci es where a hyperlink should be opened. A target value of "_blank" will tell the browser to open the hyperlink in a new tab in modern browsers, or in a new window in older browsers or if the browser has had settings changed to open hyperlinks in a new window. |
src | src Attribute | The src attribute specifies the URL or path of the image to be displayed. |
lang | lang Attribute | The <html> element has a lang attribute which specifies the document language. |
HTML Links
A link is an element that, when clicked, redirects the user to another web page. Links are usually text-based, but they can also be an image or otherwise.
Tag | Name | Description |
---|---|---|
<a> | Anchor | The <a> anchor element is used to create hyperlinks in an HTML document. The hyperlinks can point to other webpages,les on the same server, a location on the same page, or any other URL via the hyperlink reference attribute, href. The href determines the location the anchor element points to. |
Link to a Different Part of the Page #
The anchor element <a> can create hyperlinks to different parts of the same HTML document using the href attribute to point to the desired location with # followed by the id of the element to link to.
<a href="#bottom">Take me to a bottom part of the page</a>
<div>
<p id="bottom">A
bottom part of the page!</p>
</div>
Creating text links
The <a> anchor element is used to create hyperlinks in an HTML document. The hyperlinks can point to other webpages, les on the same server, a location on the same page, or any other URL via the hyperlink reference attribute, href. The href determines the location the anchor element points to.
<a href="https://developer.mozilla.org/en-US">This site.</a>
Creating image links
Images can also be used as links.
<a href="https://www.codecademy.com"><img src="logo.jpg">Click this image.</a>