What is HTML?
HTML stands for Hypertext Markup Language.
It is the standard markup language for creating content and structure of a webpage.
HTML stands for Hypertext Markup Language.
It is the standard markup language for creating content and structure of a webpage.
<myElement>myContent</myElement>
HTML consists of a series of elements which tell the browser how to display the content.
An HTML element is defined by an open tag (<myElement>), followed by some contents (myContent) and
a closed-tag (</myElement>).
For myContent, it could be a text or another HTML element nested in it.
HTML tag names are case-insensitive, it is a widely accepted convention and best practice to write them in lowercase.
Example; <h1>Hello World!</h1>, <p>Lorem Ipsum</p>, <div>myContent</div>, etc.
<myElement>
Void elements cannot have any content and only have a start tag.
Example; <img>, <hr>, <br>, etc.
<myElement myAttribute="myValue">myContent</myElement>
An attribute is a value for an HTML element to adjust the behavior for the element.
It is placed inside the opening tag of an HTML element.
The myValue can be a string or a number, depending on the attribute used for the specific element.
<!DOCTYPE html><html lang="en"><head><!-- Browser Tab --><title>MyProjectName</title><link rel="icon" type="image/x-icon" href="MyLogo"<!-- Metadata --><meta name="author" content="MyName"><meta name="description" content="MyDescription"><meta name="keywords" content="Keyword1, Keyword2, ..."><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta charset="utf-8"><link rel="stylesheet" href="MyFile"></head><!-- Open Graph Protocol --><meta property="og:title" content="MyTitle"><meta property="og:type" content="website"><meta property="og:image" content="MyLogo"><meta property="og:url" content="MyPageURL"><body><header></header><main></main><footer></footer></body></html>HTML Boilerplate is a ready-made template for the webpages.
A boilerplate includes the basic structure and essential elements every HTML document needs.
It saves developer time and helps ensure the pages are set up properly.
Nesting is placing elements inside another element.
Indentation is nested elements that placed two spaces further to the right of the element they are nested in.
It is used to make HTML easier to read.
It ensures the pages are structured correctly and work well across different browsers.
Using a boilerplate helps developers avoid common mistakes and follow best practices.
It's a great starting point for any web project.
Plus, they can customize their own boilerplate to fit their needs.
As developer gain experience, they might add their own preferred elements or meta tags.
Accessibility is making websites that everyone can understand and interact with, including people with visual, auditory, motor, and cognitive disabilities.
The following are group of people that has disabilities; Blindness, Low vision, Color blindness, Deafness, Difficulty using keyboards, mice, or touchscreens, Attention disorders, Memory issues, Difficulty speaking or understanding spoken language and Sensitivity to flashing lights.
SEO is a practice that optimizes web pages so they become more visible and rank higher on search engines.
Meta element is a great example to improve the site's SEO.
<meta name="description" content="MyDescription">
By setting the name="description", it ensures that browsers, search engines, and other web tools correctly interpret this metadata.
The content="MyDescription" is where developer will place their description.
It is recommended that the descriptions are short and concise.
This is because search engines will often truncate the description based on the results page layout.
The page description can be found in the search engine results page snippet.
Open Graph Protocol enables developer to control how their website's content appears across various social media platforms.
When the content is shared on social media, well-crafted OG properties can enhance the appearance for their content in users' feeds.
This can lead to higher click-through rates which could signal to search engines that the content is relevant and engaging.
<meta property="og:title" content="MyTitle">
This is where developer will write the title they want to be displayed for social media sites.
<meta property="og:type" content="website">
This is used to represent the type of content being shared on social media.
Other examples could be articles, websites, videos, music.
<meta property="og:image" content="MyLogo">
This open graph image is pointing to the image developer placed.
All of these images should be high quality with good dimensions and ratios.
Most social media platforms will include criteria for image requirements to help developer ensure that their content displays well on their site.
Use images that are at least 1200 by 630 pixels for the best display on high resolution devices.
At the minimum, developer should use images that are 600 by 315 pixels to display link page posts with larger images.
<meta property="og:url" content="MyPageURL">
This open graph url is pointing to the URL of the page.
There are many more OG properties that developer can set, like description, audio, video, locale.
World Wide Web Consortium (W3C) developed a set of international standards that developer can follow to make their websites more accessible and easier to use for people with disabilities.
These guidelines are designed with four core principles, known as POUR.
Users must be able to perceive the information that developer are presenting.
For example, developer can provide alternative text for images, so users who access the website with a screen reader can understand them.
<img alt="MyAlternativeText">.
Users must be able to interact with the user interface.
For example, developer can make sure that all functionality is accessible through the keyboard too, not just the mouse.
Users must be able to understand the information.
For example, developer can avoid complex sentences and use simple language as much as possible.
A wide range of browsers and other tools, including assistive technologies, must be able to interpret the content.
It describes the content of the elements, so it's much easier to read, understand, and maintain.
Search engines can easily understand the website when developer use semantic HTML.
It's also helpful for accessibility purposes, because screen readers need semantic information to describe what's on the web page.
For example, the semantic meaning of a p element, is a paragraph of text.
The div element is one of the very few that does not represent semantic HTML.
Using proper semantic HTML will improve accessibility and ensure the best experience for users with assistive technology like screen readers.
It can also improves SEO.
Improve development experience.
The most important aspect of creating a structural hierarchy is the proper use of heading elements.
Heading elements are numbered as h1, h2, h3, and so on.
These numbers represent the heading level for that element.
Ensure to use correct order in heading levels and never skip the level.
Each page should have a single h1 element representing the main topic or title.
The h2 element is a sub-heading and should be come after h1 (it can have multiple h2 per page).
Use headings in a hierarchy that reflects clear organization.
Don't skip from h1 to h3, or from h2 to h4, and so on.
Use clear and descriptive text that summarizes the content that follows each heading.
Don't use a heading in isolation - some content must follow the heading.
Use appropriate headings where necessary instead of formatting text to look like headings.
Using the right hierarchy is important for accessibility.
Assistive technologies, like screen readers, rely on the structure of a web page to determine how to parse and announce that web page to the user.
Proper structure is also important for SEO.
Search engines use automation to parse the content of the web page and determine when and where it should show up in results.
If the structure is malformed, search engines may not be able to rank very well in the relevant search results.
Depending on how incorrect the structure is, the HTML may not even be technically valid.
When this happens, the web browser has to effectively guess what the developer meant to do.
And what it guesses might not even be what the developer want at all.
It's a specification that enhances accessibility for dynamic content and UI (User Interface) components.
Note that WCAG and WAI-ARIA are not the same.
WCAG provides general guidelines for web accessibility, while WAI-ARIA offers specific rules for making dynamic and interactive content accessible for users of assistive technologies.
So, the primary purpose of WAI-ARIA is to improve accessibility for dynamic content and UI components that do not have native HTML equivalents.
WAI-ARIA works by introducing a set of attributes developer can add to HTML elements to provide additional semantic information.
These attributes are categorized into roles, states, and properties.
role AttributeARIA roles specify the semantic meaning of HTML elements.
They're essential for making web content accessible to people who use assistive technologies, like screen readers.
HTML has semantic and non-semantic elements, based on whether they convey meaning about their content.
Many semantic HTML elements already have an ARIA role assigned by default.
For example, the button element has a default ARIA role of button.
But non-semantic elements don't have a role.
For example, screen readers will not know how to interpret the purpose of a div if developer don't specify its role explicitly.
Example; <div>Click Me</div>
To specify the ARIA role of an element, add the role attribute where value is the name of a role in the ARIA specification.
Example; <div role="button">Click Me</div>
By putting role="button" in an element, developer is indicating to assistive technology that the element is a button.
Roles do not provide any functionality however.
Merely giving this div a role of button will not make it act like a button.
To make it look and behave like a button developer would need to use CSS and JavaScript to get the desired result.
Document structure roles define the overall structure of the web page.
With these roles, assistive technologies can understand the relationships between different sections and help users navigate the content.
Examples; toolbar, tooltip, feed, math, presentation, none, note.
However, most of the document structure roles are not used in modern web development because browsers already support equivalent semantic HTML elements, which should be prioritized whenever possible.
Example; <div role="math" aria-label="x squared + y squared = 3"> x<sup>2</sup> + y<sup>2</sup> = 3 </div>
The aria-label attribute is used to represent the expression.
Widget roles define the purpose and functionality of interactive elements, like scrollbars.
Example; scrollbar, searchbox, separator (when focusable), slider, spinbutton, switch, tab, tabpanel, treeitem.
Landmark roles classify and label the primary sections of a web page.
Screen readers use them to provide convenient navigation to important sections of a page.
Example; banner, complementary, contentinfo, form, main, navigation, region, search.
Each of these roles has a corresponding HTML equivalent, such as header, footer, aside, form, main, nav, section, and search.
Live region roles define elements with content that will change dynamically.
This way, screen readers and other assistive technologies can announce changes to users with visual disabilities.
Example; alert, log, marquee, status, timer.
Window roles define sub-windows, like pop up modal dialogues.
Example; alertdialog, dialog.
It is a best practice to use the HTML dialog element and its associated JavaScript methods instead of manually creating a dialog
Abstract roles help organize the document.
They're only meant to be used internally by the browser, not by developers, so you should know that they exist but you shouldn't use them on your websites or web applications.
aria-labelledby PropertyThe aria-labelledby property lets an element connect to a specific label.
<h2 id="header-id">About Me</h2>
<button id="button-id" aria-labelledby="header-id button-id">Learn More</button>
This will make the elements understandable and navigable for users of assistive technologies.
To get the best out of WAI-ARIA, try to stick with native HTML whenever possible since it generally provides more accessibility out of the box.
aria-label vs aria-labelledby
The aria-label attribute is an invisible label for interactive elements.
It adds a text label to an element that screen readers can read.
It is especially useful for elements that do not have visible text but still need to be described by screen readers.
For input elements, the aria-label attribute provides a label directly if there isn't a visible label associated with the input.
The aria-labelledby attribute does the exact same thing as the aria-label attribute, but instead of defining the text directly
in the attribute, developer use a reference to text that already exists on the page.
The existing text must have an id attribute, which will be used for the reference value in the aria-labelledby attribute.
<input type="text" aria-labelledby="search-btn">
<button type="button" id="search-btn">Search</button>
In this case, the text for the button is being used as the label for the search input.
Screen readers will announce the input as something like Search, edit.
If developer later decide they want to change the button text to Find, the label for the input will automatically be updated to the new text since it is referencing the button text.
Combining multiple id values into a single aria-labelledby attribute value is also possible.
aria-labelledby is better than aria-label
If someone is using a translation service to translate the content on the page, the text in an aria-label attribute may not always be translated.
Using aria-labelledby can also help prevent a mismatch between the visible label text and the invisible label for screen reader users since updating
the visible text will automatically update the invisible label.
aria-labelledby can make it much easier to programmatically create complex invisible labels consisting of multiple sources of text.
aria-hidden AttributeThe attribute hides the element and all of its children from the accessibility tree, while keeping them visible on the page.
The attribute does not remove it from the DOM.
Basic syntax: aria-hidden="true"
Setting aria-hidden to false will not expose the element to assistive technologies if any of its parents has this attribute set to true.
Common use cases include; Icons and images that only have a decorative purpose and Duplicated content.
The attribute only hides content from assistive technology, such as screen readers.
Developer should never use aria-hidden to hide an element that is focusable with the keyboard.
aria-hidden are not necessary to be used
The HTML element already has a hidden attribute.
The element or the element's ancestor is already hidden with display: none.
The element or the element's ancestor is already hidden with visibility: hidden.
For this, the element is already removed from the DOM and thus hidden from the accessibility tree, so the aria-hidden attribute is not necessary.
aria-describedby AttributeThe attribute is used to provide additional information about an element to screen reader users by referencing existing content on the page.
It creates a programmatic association between the element and the content (technically referred to as an accessible description), which screen readers can use to inform users of the additional information when they interact with the element.
The most common use for aria-describedby is to associate instructions and error messages with form inputs.
Due to the various methods screen reader users have for navigating a page, they may miss these messages when navigating between inputs.
Using aria-describedby helps ensure that they will hear them.
<!-- --> Defines a comment<!DOCTYPE> Defines the document type<a> Defines a hyperlink<abbr> Defines an abbreviation or an acronym<address> Defines contact information for the author/owner of a document<area> Defines an area inside an image map<article> Defines an article<aside> Defines content aside from the page content<audio> Defines embedded sound content<b> Defines bold text<base> Specifies the base URL/target for all relative URLs in a document<bdi>
Isolates a part of text that might be formatted in a different direction from other text outside it
<bdo> Overrides the current text direction<blockquote> Defines a section that is quoted from another source<body> Defines the document's body<br> Defines a single line break<button> Defines a clickable button<canvas> Used to draw graphics, on the fly, via scripting (usually JavaScript)<caption> Defines a table caption<cite> Defines the title of a work<code> Defines a piece of computer code<col> Specifies column properties for each column within a column group element<colgroup> Specifies a group of one or more columns in a table for formatting<data> Adds a machine-readable translation of a given content<datalist> Specifies a list of pre-defined options for input controls<dd> Defines a description/value of a term in a description list<del> Defines text that has been deleted from a document<details> Defines additional details that the user can view or hide<dfn> Specifies a term that is going to be defined within the content<dialog> Defines a dialog box or window<div> Defines a division in a document<dl> Defines a description list<dt> Defines a term/name in a description list<em> Defines emphasized text <embed> Defines a container for an external application<fieldset> Groups related elements in a form<figcaption> Defines a caption for a figure element<figure> Specifies self-contained content<footer> Defines a footer for a document or section<form> Defines an HTML form for user input<h1> - <h6> Defines HTML headings<head> Contains metadata/information for the document<header> Defines a header for a document or section<hgroup> Defines a header and related content<hr> Defines a thematic change in the content<html> Defines the root of an HTML document<i> Defines a part of text in an alternate voice or mood<iframe> Defines an inline frame<img> Defines an image<input> Defines an input control<ins> Defines a text that has been inserted into a document<kbd> Defines keyboard input<label> Defines a label for an input element<legend> Defines a caption for a fieldset element<li> Defines a list item<link> Defines the relationship between a document and an external resource<main> Specifies the main content of a document<map> Defines an image map<mark> Defines marked/highlighted text<menu> Defines an unordered list<meta> Defines metadata about an HTML document<meter> Defines a gauge - scalar measurement within a known range<nav> Defines navigation links<noscript> Defines an alternate content for users that do not support client-side scripts<object> Defines a container for an external application<ol> Defines an ordered list<optgroup> Defines a group of related options in a drop-down list<option> Defines an option in a drop-down list<output> Defines the result of a calculation<p> Defines a paragraph<param> Defines a parameter for an object<picture> Defines a container for multiple image resources<pre> Defines preformatted text<progress> Represents the progress of a task<q> Defines a short quotation<rp> Defines what to show in browsers that do not support ruby annotations<rt> Defines an explanation/pronunciation of characters (for East Asian typography)<ruby> Defines a ruby annotation (for East Asian typography)<s> Defines text that is no longer correct<samp> Defines sample output from a computer program<script> Defines a client-side script<search> Defines a search section<section> Defines a section in a document<select> Defines a drop-down list<small> Defines smaller text<source> Defines multiple media resources for media elements (Audio & Video)<span> Defines a section in a document<strong> Defines important text<style> Defines style information for a document<sub> Defines subscripted text<summary> Defines a visible heading for a details element<sup> Defines superscripted text<svg> Defines a container for SVG graphics<table> Defines a table<tbody> Groups the body content in a table<td> Defines a cell in a table<template> Defines a container for content that should be hidden when the page loads<textarea> Defines a multiline input control<tfoot> Groups the footer content in a table<th> Defines a header cell in a table<thead> Groups the header content in a table<time> Defines a specific time (or datetime)<title> Defines a title for the document<tr> Defines a row in a table<track> Defines text tracks for media elements (Audio & Video)<u> Defines some text that is unarticulated and styled differently from normal text<ul> Defines an unordered list<var> Defines a variable<video> Defines embedded video content<wbr> Defines a possible line-breakThe comment tag is used to insert comments in the source code.
Comments are not displayed in the browsers.
Developer can use comments to explain the code, which can help them when they edit the source code at a later date.
This is especially useful if developer have a lot of code.
All HTML documents must start with a <!DOCTYPE> declaration.
The declaration is not an HTML tag, but it is an "information" to the browser about what document type to expect.
Therefore, this <!DOCTYPE html> declaration defines that this is an HTML 5 document (latest version of HTML).
The <!DOCTYPE> declaration can be written either in uppercase, lowercase or mixed.
The <abbr> tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.", "Dr.", "ASAP".
HTML Global AttributesHTML Event Attributesabbr { display: inline; }
title attribute
This is the best way to show the description for the abbreviation/acronym.
User just simply mouse over the element and the desription will be displayed.
The <address> tag defines the contact information for the author/owner of a document or an article.
The contact information can be an email address, URL, physical address, phone number, social media handle, etc.
HTML Global AttributesHTML Event Attributesaddress { display: block; font-style: italic; }
The <a> tag defines a hyperlink, which is used to link from one page to another.
A link's text must be placed between the opening and closing tags of an anchor element.
HTML Global AttributesHTML Event Attributes<a download="myValue"><a href="myValue"><a hreflang="myValue"><a media="myValue"><a ping="myValue"> <a referrerpolicy="myValue">
<a rel="myValue"><a target="myValue"><a type="myValue">a:link, a:visited { color: (internal value); text-decoration: underline; cursor: auto; }
a:link:active, a:visited:active { color: (internal value); }
href attribute
The href attribute indicates the link's destination for <a> tag.
If the href attribute is omitted, it is only a placeholder for a hyperlink.
target attribute
By default, a linked page is displayed in the current browser window.
For some feature, it it beneficial when user specify another target so that the webpage is displayed on new tab without changing current webpage.
The <area> tag defines an area inside an image map (an image map is an image with clickable areas).
<area> elements are always nested inside a <map> tag.
HTML Global AttributesHTML Event Attributes<area alt="myValue"><area coords="myValue"><area download="myValue"><area href="myValue"><area hreflang="myValue"><area media="myValue"><area referrerpolicy="myValue">
<area rel="myValue"><area shape="myValue"><area target="myValue"><area type="myValue">area { display: none; }
name attribute
Since <area> elements nested within <map>, the elements also needed <img> too.
The name attribute will be associated with the <img>'s usemap attribute and creates a relationship between the image and the map.
The <article> tag specifies independent, self-contained content.
Potential sources for the <article> element are like forum post, blog post, news story.
HTML Global AttributesHTML Event Attributesarticle { display: block; }
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.
The <aside> content is often placed as a sidebar in a document.
HTML Global AttributesHTML Event Attributesaside { display: block; }
The <audio> tag is used to embed sound content in a document, such as music or other audio streams.
The MyText between the <audio> tags will only be displayed in browsers that do not support the audio element.
There are three supported audio formats in HTML: MP3, WAV, and OGG.
HTML Global AttributesHTML Event Attributes<audio autoplay><audio controls><audio loop><audio muted><audio preload="myValue"><audio src="myValue"><source> tags within <audio>
The <audio> tag can contains one or more <source> tags with different audio sources.
The browser will choose the first source it supports.
The <b> tag specifies bold text without any extra importance.
HTML Global AttributesHTML Event Attributesb { font-weight: bold; }
The <base> tag specifies the base URL and/or target for all relative URLs in a document.
Hence, the <base> tag must have either href or target attribute present, or both.
There can only be one single <base> element in a document, and it must be inside the <head> element.
HTML Global Attributes<base href="myValue"><base target="myValue">The <bdi> tag isolates a part of text that might be formatted in a different direction from other text outside it.
This element is useful when embedding user-generated content with an unknown text direction.
HTML Global AttributesHTML Event AttributesThe <bdo> tag is used to override the current text direction.
HTML Global AttributesHTML Event Attributesbdo { unicode-bidi: bidi-override; }
dir attribute
The attribute is obviously required that specifies the text direction of the text inside the <bdo> element.
The <blockquote> tag specifies a section that is quoted from another source.
HTML Global AttributesHTML Event Attributes<blockquote cite="myValue">blockquote { display: block; margin: 1em 40px; }
The <body> tag defines the document's body.
The <body> element contains all the contents of an HTML document, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
There can only be one <body> element in an HTML document.
HTML Global AttributesHTML Event Attributesbody { display: block; margin: 8px; }
body:focus { outline: none; }
The <br> tag inserts a single line break.
The <br> tag is useful for writing addresses or poems.
Use the <br> tag to enter line breaks, not to add space between paragraphs.
HTML Global Attributes
HTML Event Attributes
The <button> tag defines a clickable button.
Inside a <button> element user can put text, or tags <i>, <b>, <strong>, <br>, <img>, etc.
That is not possible with a button created with the <input> element.
HTML Global AttributesHTML Event Attributes<button autofocus><button disabled><button form="myValue"><button formaction="myValue">
<button formenctype="myValue">
<button formmethod="myValue">
<button formnovalidate="myValue">
<button formtarget="myValue">
<button popovertarget="myValue">
<button popovertargetaction="myValue">
<button name="myValue"><button type="myValue"><button value="myValue">The <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript).
The <canvas> tag is transparent, and is only a container for graphics, user must use a script to actually draw the graphics.
The MyText will be displayed in browsers with JavaScript disabled and in browsers that do not support canvas.
HTML Global AttributesHTML Event Attributes<canvas height="MyValue"><canvas width="MyValue">canvas { height: 150px; width: 300px; }
The <caption> tag defines a table caption.
HTML Global AttributesHTML Event Attributescaption { display: table-caption; text-align: center; }
The <cite> tag defines the title of a creative work.
Example of creative works include books, poems, songs, movies, paintings, sculptures, etc.
HTML Global AttributesHTML Event Attributescite { font-style: italic; }
The <code> tag is used to define a piece of computer code.
HTML Global AttributesHTML Event Attributescode { font-family: monospace; }
The <col> tag specifies column properties for each column within a <colgroup> element.
The <col> tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.
HTML Global AttributesHTML Event Attributes<col span="myValue">col { display: table-column; }
The <colgroup> tag specifies a group of one or more columns in a table for formatting.
HTML Global AttributesHTML Event Attributes<colgroup span="myValue">colgroup { display: table-column-group; }
<colgroup> element
The <colgroup> tag must be a child of a <table> element, and after any <caption> elements.
The <thead>, <tbody>, <tfoot>, <tr> elements should be placed after <colgroup>.
To define different properties to a column within a <colgroup>, use the <col> tag within it.
The <data> tag is used to add a machine-readable translation of a given content.
This element provides both a machine-readable value for data processors, and a human-readable value for rendering in a browser.
HTML Global Attributes<data value="MyValue">The <datalist> tag specifies a list of pre-defined options for an <input> element.
HTML Global AttributesHTML Event AttributesThe <datalist> tag is used to provide an "autocomplete" feature for <input> elements.
Users will see a drop-down list of pre-defined options as they input data.
The <datalist> element's id attribute must be equal to the <input> element's list attribute.
The <dfn> tag specifies a term that is going to be defined within the content.
The nearest parent of the <dfn> tag must also contain the definition/explanation for the term.
HTML Global AttributesHTML Event Attributesdfn { font-style: italic; }
The <del> tag defines text that has been deleted from a document.
HTML Global AttributesHTML Event Attributes<del cite="MyValue"><del datetime="MyValue">del { text-decoration: line-through; }
The <dd> tag is used to describe a data in a description list.
The <dd> tag is used in conjunction with <dl> and <dt>.
HTML Global AttributesHTML Event Attributesdd { display: block; margin-left: 40px; }
The <dl> tag defines a description list.
The <dl> tag is used in conjunction with <dt> and <dd>.
HTML Global AttributesHTML Event Attributesdl { display: block; margin: 1em 0; }
The <dt> tag defines a term/name in a description list.
The <dt> tag is used in conjunction with <dl> and <dd>.
HTML Global AttributesHTML Event Attributesdt { display: block; }
The <details> tag specifies additional details that the user can open and close on demand.
The <details> tag is often used to create an interactive widget that the user can open and close.
By default, the widget is closed and when open, it expands, and displays the content within.
The <summary> tag is used in conjunction with <details> to specify a visible heading for the details.
HTML Global AttributesHTML Event Attributes<details open>details { display: block; }
The <dialog> tag defines a dialog box or subwindow.
The <dialog> element makes it easy to create popup dialogs and modals on a web page.
HTML Global AttributesHTML Event Attributes<dialog open="MyValue">The <div> tag defines a division in an HTML document.
The <div> tag is widely used as a container for HTML elements, which is then styled with CSS or manipulated with JavaScript.
HTML Global AttributesHTML Event Attributesdiv { display: block; }
The <embed> tag defines a container for an external resource, such as a web page, a picture, a media player, or a plug-in application.
HTML Global AttributesHTML Event Attributes<embed height="MyValue"><embed src="MyValue"><embed type="MyValue"><embed width="MyValue">embed:focus { outline: none; }
The <em> tag is used to define emphasized text.
A screen reader will pronounce the words in <em> with an emphasis, using verbal stress.
HTML Global AttributesHTML Event Attributesem { font-style: italic; }
The <fieldset> tag is used to group related elements in a form.
The <fieldset> tag draws a box around the related elements.
HTML Global AttributesHTML Event Attributes<fieldset disabled"><fieldset form="myValue"><fieldset name="myValue">fieldset { display: block; margin: 0 2px; padding: 0.35em 0.75em 0.625em; border: 2px groove (internal value); }
legend element together
The legend element is used to name the section of the fieldset.
The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
While the content of the <figure> element is related to the main flow, its position is independent of the main flow.
It should not affect the flow of the document if removed.
The <figcaption> element is used to add a caption for the <figure> element.
HTML Global AttributesHTML Event Attributesfigure { display: block; margin: 1em 40px; }
The <figcaption> tag defines a caption for a <figure> element.
The <figcaption> element can be placed as the first or last child of the <figure> element.
HTML Global AttributesHTML Event Attributesfigcaption { display: block; }
The <form> tag is used to create an HTML form for user input.
HTML Global AttributesHTML Event Attributes<form accept-charset="myValue">
<form action="myValue"><form autocomplete="myValue">
<form enctype="myValue"><form method="myValue"><form name="myValue"><form novalidate><form rel="myValue"><form target="myValue">form { display: block; margin-top: 0em; }
The <head> tag is a container for metadata, placed between the <html> tag and the <body> tag.
Metadata typically define the document title, character set, styles, scripts, and other meta information, which they are not displayed in webpage.
Hence, tags like <title>, <style>, <base>, <link>, <meta> are commonly placed here.
The <script> and <noscript> can also be placed here eventhough they are not considered the essential parts of the page structure.
HTML Global Attributeshead { display: none; }
The <header> element represents a container for various purposes, depending on user's needed.
Mostly, it is represents introductory content, including heading elements (<h1> - <h6>) and some authorship informations.
Other than that, the element also provide a space for a set of navigational links, logo or icons.
HTML Global AttributesHTML Event Attributesheader { display: block; }
header tag
User can have several <header> elements in one HTML document.
However, the element cannot be placed within a <footer>, <address> or another <header> element.
The <h1> to <h6> tags are used to define HTML headings.
<h1> defines the most important heading while <h6> defines the least important heading.
HTML Global AttributesHTML Event Attributesh1 { display: block; font-weight: bold; font-size: 2em; margin: 0.67em 0; }
h2 { display: block; font-weight: bold; font-size: 1.5em; margin: 0.83em 0; }
h3 { display: block; font-weight: bold; font-size: 1.17em; margin: 1em 0; }
h4 { display: block; font-weight: bold; font-size: 1em; margin: 1.33em 0; }
h5 { display: block; font-weight: bold; font-size: 0.83em; margin: 1.67em 0; }
h6 { display: block; font-weight: bold; font-size: 0.67em; margin: 2.33em 0; }
<h1> tag
Only use one <h1> per page, which it should represent the main heading/subject for the whole page.
Do not skip heading levels, start with <h1>, then use <h2>, and so on until <h6>.
The <hgroup> tag is used to surround a heading and one or more <p> elements.
The heading inside the <hgroup> element can be any of the <h1> to <h6> headings.
HTML Global AttributesHTML Event Attributeshgroup { display: block; }
The <hr> tag defines a thematic break in an HTML page.
The <hr> element is most often displayed as a horizontal rule that is used to separate content in an HTML page.
HTML Global AttributesHTML Event Attributeshr { display: block; margin: 0.5em auto; border-style: inset; border-width: 1px; }
The <html> tag represents the root of an HTML document.
The <html> tag is the container for all other HTML elements except for the <!DOCTYPE> declaration.
HTML Global Attributes<html xmlns="myValue">html { display: block; }
html:focus { outline: none; }
lang attribute
Always include the lang attribute inside the <html> tag, to declare the language of the webpage.
This is meant to assist search engines and browsers.
The <img> tag is used to embed an image in an HTML page.
Images are not technically inserted into a web page, images are linked to web pages.
The <img> tag creates a holding space for the referenced image.
HTML Global AttributesHTML Event Attributes<img alt="myValue"><img crossorigin="myValue">
<img height="myValue"><img ismap><img loading="myValue"><img longdesc="myValue"><img referrerpolicy="myValue">
<img sizes="myValue"><img src="myValue"><img srcset="myValue"><img usemap="myValue"><img width="myValue">img { display: inline-block; }
src, alt, width, height attributes
The src attribute specifies the path to the image.
The alt attribute is used for screen readers to improve accessibility and is displayed if the image fails to load.
Always specify the width and height of an image because if they are omitted, the page might flicker while the image loads.
To link an image to another document, simply nest the <img> tag inside an <a> tag.
When preparing an image, the image should be scaled to a 640x480 size (width=640px, height=480px).
If the image size is 1920x1080 but styling it to be much smaller, the users may be required to download unnecessary data.
A smaller resolution results in a smaller file size.
Developer should consider using a more optimized format, like WEBP or AVIF.
Two of the most common file formats are PNG and JPG, but these are no longer the most ideal formats for serving images.
A compression algorithm is used to reduce the size for files or data.
There are options like pngcrush to compress the images locally, or developer can use online compression tools.
However, it's worth noting that specific file formats, such as JPG, are not lossless.
Lossless means that the original data can be perfectly reconstructed from the compressed data.
Example, if the JPG image is compressed, it will result in a degraded quality.
Images are considered intellectual property, this means that they are protected by copyright regulations, most often belonging to the creator.
By default, images are released as all rights reserved.
The creator, or publisher sometimes, holds all copyright for the image.
This means that developer cannot use them in their web page unless they do one of three things:
Obtain written permission from the copyright holder
Purchase a license from the copyright holder
Incorporate the image in a way that falls under fair use
Fair use requires that their use of the image is both limited and transformative.
Some examples of fair use would be to comment on or review the art or create a parody of the image.
Some images might be released under a permissive license, like a Creative Commons license, or the BSD license.
Developer might be required to make their website open source, or they may not be permitted to modify the image in any way.
An image under the public domain has no copyright attached to it and is free to be used without any restrictions.
Images licensed specifically under the Creative Commons 0 license are considered public domain.
There are also sites like Pixabay and Unsplash, which offer free-to-use images.
The <iframe> tag specifies an inline frame.
An inline frame is used to embed another document within the current HTML document.
HTML Global AttributesHTML Event Attributes<iframe allow="MyValue"><iframe allowfullscreen="MyValue">
<iframe allowpaymentrequest="MyValue">
<iframe height="MyValue"><iframe loading="MyValue"><iframe name="MyValue"><iframe referrerpolicy="MyValue">
<iframe sandbox="MyValue"><iframe src="MyValue"><iframe srcdoc="MyValue"><iframe width="MyValue">iframe:focus { outline: none; }
iframe[seamless] { display: block; }
The <input> tag specifies an input field where the user can enter data.
The <input> element is the most important form element.
The <input> element can be displayed in several ways, depending on the type attribute.
HTML Global AttributesHTML Event Attributes<input accept="myValue"><input alt="myValue"><input autocomplete="myValue">
<input autofocus><input checked><input dirname="myValue"><input disabled><input form="myValue"><input formaction="myValue">
<input formenctype="myValue">
<input formmethod="myValue">
<input formnovalidate><input formtarget="myValue">
<input height="myValue"><input list="myValue"><input max="myValue"><input maxlength="myValue"><input min="myValue"><input minlength="myValue"><input multiple<input name="myValue"><input pattern="myValue"><input placeholder="myValue">
<input popovertarget="myValue">
<input popovertargetaction="myValue">
<input readonly><input required><input size="myValue"><input src="myValue"><input step="myValue"><input type="myValue"><input value="myValue"><input width="myValue"><label> tag together
It serves greater accessibility for the following <input> elements:
<input type="text">, <input type="checkbox">, <input type="radio">, <input type="file">, <input type="password">
The <ins> tag defines a text that has been inserted into a document.
HTML Global AttributesHTML Event Attributes<ins cite="myValue"><ins datetime="myValue">ins { text-decoration: underline; }
The <i> tag defines a part of text in an alternate voice or mood.
The <i> tag is often used to indicate a technical term, a phrase from another language, a thought, a ship name, etc.
HTML Global AttributesHTML Event Attributesi { font-style: italic; }
The <kbd> tag is used to define keyboard input.
HTML Global AttributesHTML Event Attributeskbd { font-family: monospace; }
The <label> tag defines a label for several elements.
HTML Global AttributesHTML Event Attributes<label for="myValue"><label form="myValue">label { cursor: default; }
Without <label>, some users will have difficulty clicking on very small regions.
With <label>, this increases the hit area and they can clicks the text within the label element.
Other than that, it can serve as screen reader users (will read out loud the label, when the user is focused on the element).
<label> tag
Only selective elements of the following can be bounded with label element:
<input type="checkbox">, <input type="color">, <input type="date">, <input type="datetime-local">, <input type="email">,
<input type="file">, <input type="month">, <input type="number">, <input type="password">, <input type="radio">,
<input type="range">, <input type="search">, <input type="tel">, <input type="text">, <input type="time">, <input type="url">,
<input type="week">, <meter>, <progress>, <select>, <textarea>
The <legend> tag defines a caption for the <fieldset> element.
HTML Global AttributesHTML Event Attributeslegend { display: block; padding: 0 2px; border: none; }
The <link> tag is used to link to external resources.
The <link> tag should be placed inside the <head> tag.
There can be multiple link elements that link to different stylesheets, fonts, icons, etc.
It is considered best practice to separate HTML and CSS in different files.
Developers will use the link element for their external CSS file instead of writing everything in the HTML document.
HTML Global AttributesHTML Event Attributes<link crossorigin="myValue">
<link href="myValue"><link hreflang="myValue"><link media="myValue"><link referrerpolicy="myValue">
<link rel="myValue"><link sizes="myValue"><link type="myValue">link { display: none; }
A favicon is a small image displayed next to the page title in the browser tab.
User can use any image as the desired favicon, or can also create "custom favicon" on the site.
The favicon should be a simple image with high contrast due to its small size.
The attributes required for creating favicon are rel, type, href.
Example; <link rel="icon" type="image/x-icon" href="myFavicon.ico">.
Google Fonts are a set of free and open source custom fonts that can be used in the page.
Example;
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin >
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Playwrite+CU:wght@100..400&display=swap">
The preconnect value tells the browser to create an early connection to the value specified in the href attribute.
This is done to speed up loading times for these external resources.
The <li> tag defines a list item.
The <li> tag is used inside <ol>, <ul>, <menu>.
In <ul> and <menu>, the list items will usually be displayed with bullet points.
In <ol>, the list items will usually be displayed with numbers or letters.
HTML Global AttributesHTML Event Attributes<li value="myValue">li { display: list-item; }
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, like sidebars, navigation links, copyright information, site logos, and search forms.
HTML Global AttributesHTML Event AttributesThere must not be more than one <main> element in a document.
The element must NOT be a descendant of an <article>, <aside>, <footer>, <header>, <nav> element.
The <map> tag is used to define an image map, where it is an image map with clickable areas.
HTML Global AttributesHTML Event Attributes<map name="myValue">map { display: inline; }
name attribute
The name attribute will be associated with the <img>'s usemap attribute and creates a relationship between the image and the map.
The <map> element contains a number of <area> elements, that defines the clickable areas in the image map.
The <mark> tag defines text that should be marked or highlighted.
HTML Global AttributesHTML Event Attributesmark { background-color: yellow; color: black; }
The <menu> tag defines an unordered list of content.
The <menu> tag is an alternative to the <ul> tag and browsers will treat these two lists equally.
Use the <menu> tag together with the <li> tag to create menu items.
HTML Global AttributesHTML Event Attributesmenu { display: block; list-style-type: disc; margin-block: 1em; margin-inline: 0; padding-inline-start: 40px; }
The <meta> tag defines metadata (informations) about an HTML document.
The tag is typically used to specify character set, page description, keywords, author of the document, and viewport settings.
Metadata will not be displayed on the page, but is machine parsable.
Metadata is used by browsers (how to display content or reload page), search engines (keywords), and other web services.
HTML Global Attributes<meta charset="myValue"><meta content="myValue"><meta http-equiv="myValue"><meta name="myValue"><meta name="viewport" content="width=device-width, initial-scale=1.0">.
This gives the browser instructions on how to control the page's dimensions and scaling.
The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).
The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.
The <meter> tag defines a scalar measurement within a known range, or a fractional value.
HTML Global AttributesHTML Event Attributes<meter form="myValue"><meter high="myValue"><meter low="myValue"><meter max="myValue"><meter min="myValue"><meter optimum="myValue"><meter value="myValue">Always add the <label> tag for best accessibility practices.
The <meter> tag is not suitable for representing a progress, use the <progress> tag instead.
The <noscript> tag defines an alternate content to be displayed that have disabled scripts in the browser.
It can also be used to display some text when a browser doesn't support script.
HTML Global Attributes<noscript> tags
The <noscript> element can be used in both <head> and <body>.
When used inside <head>, the element could only contain <link>, <style>, <meta> elements.
The <object> tag defines a container for an external resource.
The external resource can be a web page, a picture, a media player, or a plug-in application.
HTML Global AttributesHTML Event Attributes<object data="MyValue"><object form="MyValue"><object height="MyValue"><object name="MyValue"><object type="MyValue"><object typemustmatch="MyValue">
<object usemap="MyValue"><object width="MyValue">object:focus { outline: none; }
<object> mainly used for Plug-ins
The <object> tag was originally designed to embed browser Plug-ins.
Plug-ins are computer programs that extend the standard functionality of the browser.
Plug-ins have been used for many different purposes, like scan for viruses and verify a bank id.
Plug-ins have been used for running Java applets, but now most browsers no longer support Java Applets and Plug-ins.
Plug-ins have been used for running ActiveX controls, but now are no longer supported in any browser.
Plug-ins have been used for displaying Flash movies and maps, but the support for Shockwave Flash has also been turned off in modern browsers.
The <option> tag defines an option in a select list.
The <option> elements go inside a <select>, <optgroup>, or <datalist> element.
HTML Global AttributesHTML Event Attributes<option disabled><option label="myValue"><option selected><option value="myValue">The <optgroup> tag is used to group related options in a <select> element (drop-down list).
HTML Global AttributesHTML Event Attributes<optgroup disabled><optgroup label="myValue">The <ol> tag defines an ordered list.
An ordered list can be numerical or alphabetical.
HTML Global AttributesHTML Event Attributes<ol reversed="myValue"><ol start="myValue"><ol type="myValue">ol { display: block; list-style-type: decimal; margin: 1em 0; padding-left: 40px; }
The <output> tag is used to represent the result of a calculation, like one performed by a script.
HTML Global AttributesHTML Event Attributes<output for="myValue"><output form="myValue"><output name="myValue">output { display: inline; }
The <p> tag defines a paragraph.
Browsers automatically add a single blank line before and after each <p> element.
HTML Global AttributesHTML Event Attributesp { display: block; margin: 1em 0; }
The <param> tag is used to define parameters for an <object> element.
HTML Global AttributesHTML Event Attributes<param name="MyValue"><param value="MyValue">param { display: none; }
The <picture> tag gives users more flexibility in specifying image resources.
The most common use of the <picture> element will be for art direction in responsive designs.
Instead of having one image that is scaled up or down based on the viewport width, multiple images can be designed to more nicely fill the browser viewport.
The <picture> element contains two tags: one or more <source> tags and one <img> tag.
The browser will look for the first <source> element where the media query matches the current viewport width.
Then it will display the proper image (specified in the srcset attribute).
The <img> element is required as the last child of the <picture> element, as a fallback option
if none of the source tags matches.
HTML Global AttributesHTML Event AttributesThe <pre> tag defines preformatted text.
Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks.
The text will be displayed exactly as written in the HTML source code.
HTML Global AttributesHTML Event Attributespre { display: block; font-family: monospace; white-space: pre; margin: 1em 0; }
The <progress> tag represents the completion progress of a task.
HTML Global AttributesHTML Event Attributes<progress max="myValue"><progress value="myValue">Always add the <label> tag for best accessibility practices.
Use the <progress> tag in conjunction with JavaScript to display the progress of a task.
The <progress> tag is not suitable for representing a gauge, use the <meter> tag instead.
The <q> tag defines a short quotation.
HTML Global AttributesHTML Event Attributes<q cite="myValue">q { display: inline; }
q:before { content: open-quote; }
q:after { content: close-quote; }
The <ruby> tag specifies a ruby annotation.
A ruby annotation is a small extra text, attached to the main text to indicate the pronunciation or meaning of the corresponding characters.
This kind of annotation is often used in Japanese publications.
HTML Global AttributesHTML Event Attributes<ruby> together with <rt> and <rp>
The <ruby> element consists of one or more characters that needs an explanation/pronunciation.
An <rt> element gives that information.
An optional <rp> element that defines what to show for browsers that do not support ruby annotations.
The <rp> tag can be used to provide parentheses around a ruby text, to be shown by browsers that do not support ruby annotations.
HTML Global AttributesHTML Event Attributes<rp> together with <ruby> and <rt>
The <ruby> element consists of one or more characters that needs an explanation/pronunciation.
An <rt> element gives that information.
An optional <rp> element that defines what to show for browsers that do not support ruby annotations.
The <rt> tag defines an explanation or pronunciation of characters (for East Asian typography) in a ruby annotation.
HTML Global AttributesHTML Event Attributesrt { line-height: normal; }
<rt> together with <ruby> and <rp>
The <ruby> element consists of one or more characters that needs an explanation/pronunciation.
An <rt> element gives that information.
An optional <rp> element that defines what to show for browsers that do not support ruby annotations.
The <samp> tag is used to define sample output from a computer program.
HTML Global AttributesHTML Event Attributessamp { font-family: monospace; }
The <svg> tag defines a container for SVG graphics.
It sets up the space where all the shapes appear.
SVG has several methods for drawing paths, boxes, circles, text, and graphic images.
The circle element is used to draw a circle.
The path element is used to draw a curved line.
Common image formats like PNG and JPG are classified as raster formats.
This essentially means that they are pixel-based, with the data tracking the color value in each pixel.
A large downside of raster based images is that they do not upscale well.
If the PNG files is edited to be larger file, it can becomes pixelated, or blurry.
As for SVG, a vector graphic tracks data based on paths and equations to plot points, lines, and curves.
It can be scaled to any size without impacting the quality.
SVGs specifically have the added benefit of storing data in XML.
Developer can use them directly in their code as raw HTML with the SVG element.
It also means they can programmatically change the color of the image.
SVG is great for icons uses.
If developer want to create custom bullet points, or add icons to their links to represent social media platforms, using SVGs is the best approach.
One of the most popular icon libraries, Font Awesome, uses SVG images for their icons.
SVGs are also great for webpage logos, because they scale perfectly.
They allow developer to adapt their layout to any responsive design they need.
The path element defines the image shape.
The d attribute defines a series of command letters and numbers that draw a shape.
The letters represent commands like move to, draw line, and close, while the numbers represent coordinates.
The viewBox="a b c d" attribute controls what part of the image is visible inside the SVG.
The first two numbers (a b) set the starting position of the viewBox, which is the top-left corner (x and y).
The next two numbers (c d) define the viewBox's width and height.
The fill="myColor" attribute defines the color.
The <script> tag is used to embed a client-side script, usually JavaScript.
The <script> element either contains scripting statements, or it points to an external script file through the src attribute.
Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.
HTML Global Attributes<script async><script crossorigin="myValue">
<script defer><script integrity="myValue">
<script nomodule="myValue"><script referrerpolicy="myValue">
<script src="myValue"><script type="myValue">script { display: none; }
<script> and <noscript> tags
The <script> element can be used in both <head> and <body>.
In <body>, the <noscript> is used in the case of <script> have been disabled in browser.
It could also be used in the case of a browser that doesn't support client-side scripting.
The <search> tag is used to specify that here comes a set of elements that is related to search.
Elements inside a <search> elements can typically be form elements used to perform a search.
HTML Global AttributesHTML Event Attributessearch { display: block; }
The <section> tag defines a section in a document.
It is a semantic element that helps with SEO and accessibility.
HTML Global AttributesHTML Event Attributessection { display: block; }
The <select> element is used to create a drop-down list.
The <select> element is most often used in a form, to collect user input.
HTML Global AttributesHTML Event Attributes<select autofocus><select disabled><select form="myValue"><select multiple><select name="myValue"><select required><select size="myValue">The name attribute is needed to reference the form data after the form is submitted.
If the name attribute is omitted, no data from the drop-down list will be submitted.
The id attribute is needed to associate the drop-down list with a label.
The <option> tags inside the <select> element define the available options in the drop-down list.
Always add the <label> tag for best accessibility practices.
The <small> tag defines smaller text (like copyright and other side-comments).
HTML Global AttributesHTML Event Attributessmall { font-size: smaller; }
The <source> tag is used to specify multiple media resources for media elements, such as audio, video and picture.
The <source> tag allows user to specify alternative files which the browser may choose from, based on browser support or viewport width.
The browser will choose the first <source> it supports.
HTML Global AttributesHTML Event Attributes<source media="myValue"><source src="myValue"><source type="myValue">The <span> tag is an inline container used to mark up a part of a text, or a part of a document.
The <span> tag is easily styled by CSS or manipulated with JavaScript.
HTML Global AttributesHTML Event AttributesThe <s> tag specifies text that is no longer correct, accurate or relevant.
HTML Global AttributesHTML Event Attributess { text-decoration: line-through; }
The <strong> tag is used to define text with strong importance.
Use the <b> tag to specify bold text without any extra importance.
HTML Global AttributesHTML Event Attributesstrong { font-weight: bold; }
The <style> tag is used to define style information (CSS) for a document.
Inside the <style> element user can specify how HTML elements should render in a browser.
The <style> element must be included inside the <head> of the document.
HTML Global AttributesHTML Event Attributes<style media="myValue"><style type="myValue">style { display: none; }
When a browser reads a style sheet, it will format the HTML document according to the information in the style sheet.
If some properties have been defined for the same selector (element) in different style sheets, the value from the last read style sheet will be used.
There are more info regarding to CSS specificity in CSS section.
The <sub> tag defines subscript text.
Subscript text can be used for chemical formulas, like H2O.
HTML Global AttributesHTML Event Attributessub { vertical-align: sub; font-size: smaller; }
The <summary> tag defines a visible heading for the <details> element.
The heading can be clicked to view/hide the details.
The <summary> element should be the first child element of the <details> element.
HTML Global AttributesHTML Event Attributessummary { display: block; }
The <sup> tag defines superscript text.
Superscript text can be used for footnotes, like WWW[1].
HTML Global AttributesHTML Event Attributessup { vertical-align: super; font-size: smaller; }
The <table> tag defines an HTML table.
An HTML table consists of one <table> element, one or more <tr>, <th>, <td> elements.
An HTML table may also include <caption>, <colgroup>, <col>, <thead>, <tbody>, <tfoot> elements.
HTML Global Attributes
HTML Event Attributes
table { display: table; border-collapse: separate; border-spacing: 2px; border-color: gray; }
The <tbody> tag is used to group the body content in an HTML table.
HTML Global AttributesHTML Event Attributestbody { display: table-row-group; vertical-align: middle; border-color: inherit; }
<tbody> element
The <tbody> element is used in conjunction with the <thead>, <tfoot> elements to specify each part of a table.
Browsers can use these elements to enable scrolling of the table body independently of the header and footer.
When printing a large table that spans multiple pages, these elements can enable the table header and footer to be printed at the top and bottom of each page.
The <tbody> element must have one or more <tr> tags inside.
The <td> tag defines a standard data cell in an HTML table.
The text in <td> elements are regular and left-aligned by default.
HTML Global AttributesHTML Event Attributes<td colspan="myValue"><td headers="myValue"><td rowspan="myValue">td { display: table-cell; vertical-align: inherit; }
The <thead> tag is used to group header content in an HTML table.
HTML Global AttributesHTML Event Attributesthead { display: table-header-group; vertical-align: middle; border-color: inherit; }
<thead> element
The <thead> element is used in conjunction with the <tbody>, <tfoot> elements to specify each part of a table.
Browsers can use these elements to enable scrolling of the table body independently of the header and footer.
When printing a large table that spans multiple pages, these elements can enable the table header and footer to be printed at the top and bottom of each page.
The <thead> element must have one or more <tr> tags inside.
The <th> tag defines a header cell in an HTML table.
The text in <th> elements are bold and centered by default.
HTML Global AttributesHTML Event Attributes<th abbr="myValue"><th colspan="myValue"><th headers="myValue"><th rowspan="myValue"><th scope="myValue">th { display: table-cell; vertical-align: inherit; font-weight: bold; text-align: center; }
The <tr> tag defines a row in an HTML table.
A <tr> element contains one or more <th> or <td> elements.
HTML Global AttributesHTML Event Attributestr { display: table-row; vertical-align: inherit; border-color: inherit; }
The <template> tag is used as a container to hold some HTML content hidden from the user when the page loads.
The content inside <template> can be rendered later with a JavaScript.
User can use the <template> tag if they have some HTML codes to use over and over again, but not until they ask for it.
To do this without the <template> tag, user have to create the HTML code with JavaScript to prevent the browser from rendering the code.
HTML Global AttributesThe <textarea> tag defines a multi-line text input control.
The <textarea> element is often used in a form, to collect user inputs like comments or reviews.
A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).
HTML Global AttributesHTML Event Attributes<textarea autofocus><textarea cols="myValue"><textarea dirname="myValue">
<textarea disabled="myValue">
<textarea form="myValue"><textarea maxlength="myValue">
<textarea name="myValue"><textarea placeholder="myValue">
<textarea readonly><textarea required><textarea rows="myValue"><textarea wrap="myValue">The size of a text area is specified by the cols and rows attributes.
The name attribute is needed to reference the form data after the form is submitted.
Always add the <label> tag for best accessibility practices.
The <time> tag defines a specific time (or datetime).
HTML Global AttributesHTML Event Attributes<time datetime="myValue">datetime attribute
The datetime attribute of this element is used translate the time into a machine-readable format.
By doing this, browsers can offer to add date reminders through the user's calendar, and search engines can produce smarter search results.
The <title> tag defines the title of the document.
The title must be text-only, and it is shown in the browser's title bar or in the page's tab.
HTML Global Attributestitle { display: none; }
<title> element
The <title> tag is required in HTML documents.
The contents of a page title is very important for search engine optimization (SEO).
The page title is used by search engine algorithms to decide the order when listing pages in search results.
User can not have more than one <title> element in an HTML document.
<title> element
Go for a longer, descriptive title (avoid one- or two-word titles).
Search engines will display about 50-60 characters of the title, so try not to have titles longer than that.
Do not use just a list of words as the title (this may reduce the page's position in search results).
The <track> tag specifies text tracks for <audio> or <video> elements.
This element is used to specify subtitles, caption files or other files containing text, that should be visible when the media is playing.
Tracks are formatted in WebVTT format (.vtt files).
HTML Global AttributesHTML Event Attributes<track default><track kind="myValue"><track label="myValue"><track src="myValue"><track srclang="myValue">The <u> tag represents some text that is unarticulated and styled differently from normal text.
The text can be like misspelled words or proper names in Chinese text.
Avoid using the <u> element where it could be confused for a hyperlink.
HTML Global AttributesHTML Event Attributesu { text-decoration: underline; }
The <ul> tag defines an unordered list.
Use the <ul> tag together with the <li> tag to create unordered lists.
HTML Global AttributesHTML Event Attributesul { display: block; list-style-type: disc; margin: 1em 0; padding-left: 40px; }
The <var> tag is used to defines a variable in programming or in a mathematical expression.
HTML Global AttributesHTML Event Attributesvar { font-style: italic; }
The <video> tag is used to embed video content in a document, such as a movie clip or other video streams.
The MyText between the <video> tags will only be displayed in browsers that do not support the video element.
There are three supported video formats in HTML: MP4, WebM, and OGG.
HTML Global AttributesHTML Event Attributes<video autoplay><video controls><video height="myValue"><video loop><video muted><video poster="myValue"><video preload="myValue"><video src="myValue"><video width="myValue">The <wbr> tag specifies "Word Break Opportunity" where in a text it would be ok to add a line-break.
When a word is too long, the browser might break it at the wrong place.
User can use the <wbr> element to add word break opportunities.
HTML Global AttributesHTML Event Attributesaccept Specifies the types of files that the server acceptsaccept-charset Specifies the character encodings that are to be used for the form submissionaccesskey Specifies a shortcut key to activate/focus an elementaction Specifies where to send the form-data when a form is submittedalt Specifies an alternate text when the original element fails to displayasync Specifies that the script is executed asynchronously (for external scripts)autocomplete Specifies whether the element should have autocomplete enabled (for form and input)autofocus Specifies that the element should automatically get focus when the page loadsautoplay Specifies that the audio/video will start playing as soon as it is readycharset Specifies the character encodingchecked
Specifies that an input element should be pre-selected when the page loads (for checkbox and radio)
cite Specifies a URL which explains the quote/deleted/inserted textclass Specifies one or more class names for an elementcols Specifies the visible width of a text areacolspan Specifies the number of columns a table cell should spancontent Gives the value associated with the http-equiv or name attributecontenteditable Specifies whether the content of an element is editable or notcontrols Specifies that audio/video controls should be displayedcoords Specifies the coordinates of the areadata Specifies the URL of the resource to be used by the objectdata-* Used to store custom data private to the page or applicationdatetime Specifies the date and timedefault
Specifies that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate
defer Specifies that the script is executed when the page has finished parsing (for external scripts)dir Specifies the text direction for the content in an elementdirname Specifies that the text direction will be submitteddisabled Specifies that the specified element/group of elements should be disableddownload Specifies that the target will be downloaded when a user clicks on the hyperlinkdraggable Specifies whether an element is draggable or notenctype Specifies how the form-data should be encoded when submitting it to the server (for post)enterkeyhint Specifies the text of the enter-key on a virtual keyboardfor Specifies which form element(s) a label/calculation is bound toform Specifies the name of the form the element belongs toformaction Specifies where to send the form-data when a form is submittedheaders Specifies one or more headers cells a cell is related toheight Specifies the height of the elementhidden Specifies that an element is not yet, or is no longer, relevanthigh Specifies the range that is considered to be a high valuehref Specifies the URL of the page the link goes tohreflang Specifies the language of the linked documenthttp-equiv Provides an HTTP header for the information/value of the content attributeid Specifies a unique id for an elementinert Specifies that the browser should ignore this sectioninputmode Specifies the mode of a virtual keyboardismap Specifies an image as a server-side image mapkind Specifies the kind of text tracklabel Specifies the title of the text tracklang Specifies the language of the element's contentlist Refers to a datalist element that contains pre-defined options for an input elementloop Specifies that the audio/video will start over again, every time it is finishedlow Specifies the range that is considered to be a low valuemax Specifies the maximum valuemaxlength Specifies the maximum number of characters allowed in an elementmedia Specifies what media/device the linked document is optimized formethod Specifies the HTTP method to use when sending form-datamin Specifies a minimum valuemultiple Specifies that a user can enter more than one valuemuted Specifies that the audio output of the video should be mutedname Specifies the name of the elementnovalidate Specifies that the form should not be validated when submittedonabort Script to be run on abortonafterprint Script to be run after the document is printedonbeforeprint Script to be run before the document is printedonbeforeunload Script to be run when the document is about to be unloadedonblur Script to be run when the element loses focusoncanplay Script to be run when a file is ready to start playingoncanplaythrough
Script to be run when a file can be played all the way to the end without pausing for buffering
onchange Script to be run when the value of the element is changedonclick Script to be run when the element is being clickedoncontextmenu Script to be run when a context menu is triggeredoncopy Script to be run when the content of the element is being copiedoncuechange Script to be run when the cue changes in a track elementoncut Script to be run when the content of the element is being cutondblclick Script to be run when the element is being double-clickedondrag Script to be run when the element is being draggedondragend Script to be run at the end of a drag operationondragenter Script to be run when an element has been dragged to a valid drop targetondragleave Script to be run when an element leaves a valid drop targetondragover Script to be run when an element is being dragged over a valid drop targetondragstart Script to be run at the start of a drag operationondrop Script to be run when dragged element is being droppedondurationchange Script to be run when the length of the media changesonemptied Script to be run when something bad happens and the file is suddenly unavailableonended Script to be run when the media has reach the endonerror Script to be run when an error occursonfocus Script to be run when the element gets focusonhashchange Script to be run when there has been changes to the anchor part of the a URLoninput Script to be run when the element gets user inputoninvalid Script to be run when the element is invalidonkeydown Script to be run when a user is pressing a keyonkeypress Script to be run when a user presses a keyonkeyup Script to be run when a user releases a keyonload Script to be run when the element is finished loadingonloadeddata Script to be run when media data is loadedonloadedmetadata Script to be run when meta data (like dimensions and duration) are loadedonloadstart Script to be run just as the file begins to load before anything is actually loadedonmousedown Script to be run when a mouse button is pressed down on an elementonmousemove Script to be run as long as the mouse pointer is moving over an elementonmouseout Script to be run when a mouse pointer moves out of an elementonmouseover Script to be run when a mouse pointer moves over an elementonmouseup Script to be run when a mouse button is released over an elementonmousewheel Script to be run when a mouse wheel is being scrolled over an elementonoffline Script to be run when the browser starts to work offlineononline Script to be run when the browser starts to work onlineonpagehide Script to be run when a user navigates away from a pageonpageshow Script to be run when a user navigates to a pageonpaste Script to be run when the user pastes some content in an elementonpause Script to be run when the media is paused either by the user or programmaticallyonplay Script to be run when the media has started playingonplaying Script to be run when the media has started playingonpopstate Script to be run when the window's history changes.onprogress Script to be run when the browser is in the process of getting the media dataonratechange Script to be run each time the playback rate changesonreset Script to be run when a reset button in a form is clickedonresize Script to be run when the browser window is being resizedonscroll Script to be run when an element's scrollbar is being scrolledonsearch Script to be run when the user writes something in a search fieldonseeked Script to be run when the seeking attribute is set to false indicating that seeking has endedonseeking Script to be run when the seeking attribute is set to true indicating that seeking is activeonselect Script to be run when the element gets selectedonstalled Script to be run when the browser is unable to fetch the media data for whatever reasononstorage Script to be run when a Web Storage area is updatedonsubmit Script to be run when a form is submittedonsuspend
Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason
ontimeupdate Script to be run when the playing position has changedontoggle Script to be run when the user opens or closes the details elementonunload Script to be run when a page has unloaded (or the browser window has been closed)onvolumechange Script to be run each time the volume of a video/audio has been changedonwaiting Script to be run when the media has paused but is expected to resumeonwheel Script to be run when the mouse wheel rolls up or down over an elementopen Specifies that the details should be visible (open) to the useroptimum Specifies what value is the optimal value for the gaugepattern Specifies a regular expression that an input element's value is checked againstplaceholder Specifies a short hint that describes the expected value of the elementpopover Specifies a popover elementpopovertarget Specifies which popover element to invokedpopovertargetaction
Specifies what happens to the popover element when the button is clicked
poster
Specifies an image to be shown while the video is downloading, or until the user hits the play button
preload Specifies if and how the author thinks the audio/video should be loaded when the page loadsreadonly Specifies that the element is read-onlyrel Specifies the relationship between the current document and the linked documentrequired Specifies that the element must be filled out before submitting the formreversed Specifies that the list order should be descending (9,8,7...)rows Specifies the visible number of lines in a text arearowspan Specifies the number of rows a table cell should spansandbox Enables an extra set of restrictions for the content in an iframescope Specifies whether a header cell is a header for a column, row, or group of columns or rowsselected Specifies that an option should be pre-selected when the page loadsshape Specifies the shape of the areasize
Specifies the width, in characters (for input) or specifies the number of visible options (for select)
sizes Specifies the size of the linked resourcespan Specifies the number of columns to spanspellcheck Specifies whether the element is to have its spelling and grammar checked or notsrc Specifies the URL of the media filesrcdoc Specifies the HTML content of the page to show in the iframesrclang Specifies the language of the track text datasrcset Specifies the URL of the image to use in different situationsstart Specifies the start value of an ordered liststep Specifies the legal number intervals for an input fieldstyle Specifies an inline CSS style for an elementtabindex Specifies the tabbing order of an elementtarget Specifies the target for where to open the linked document or where to submit the formtitle Specifies extra information about an elementtranslate Specifies whether the content of an element should be translated or nottype Specifies the type of elementusemap Specifies an image as a client-side image mapvalue Specifies the value of the elementwidth Specifies the width of the elementwrap Specifies how the text in a text area is to be wrapped when submitted in a form