HTML formatting elements and Global attributes

HTML formatting elements and Global attributes

What are formatting elements, and global attributes in HTML?

Introduction

Till now we know about HTML tags and attributes. Now in this blog, we will explore global attributes and formatting. Formatting elements are those elements that were designed to display special types of text.

Formatting

Commenting in HTML

We use <!--this is a comment --> to comment inside an HTML file.

<b>

The HTML <b> element defines bold text without any extra importance.

<strong>

The <strong> HTML element indicates that its contents have strong importance, seriousness, or urgency. Browsers typically render the contents in bold type.

<i>

The HTML <i> element defines a part of text in an alternate voice or mood. The content inside is typically displayed in italic. The <i> tag is often used to indicate a technical term, a phrase from another language, a thought, a ship name, etc.

<em>

The HTML <em> element defines emphasized text. The content inside is typically displayed in italic. A screen reader will pronounce the words in <em> with an emphasis, using verbal stress.

<small>

The <small> The HTML element represents side comments and small print, like copyright and legal text, independent of its styled presentation. By default, it renders text within it one font size smaller, such as from small to x-small.

<sub>

The <sub> HTML element specifies inline text, which should be displayed as a subscript for solely typographical reasons. Subscripts are typically rendered with a lowered baseline using smaller text.

<sup>

The <sup> HTML element specifies inline text, which is to be displayed as superscript for solely typographical reasons. Superscripts are usually rendered with a raised baseline using smaller text.

<mark>

The <mark> HTML element represents text that is marked or highlighted for reference or notation purposes due to the marked passage's relevance in the enclosing context.

<ins>

The <ins> HTML element represents a range of text that has been added to a document. You can use the <del> element to similarly represent a range of text that has been deleted from the document.

<del>

The <del> HTML element represents a range of text that has been deleted from a document. This can be used when rendering "track changes" or source code diff information, for example. The <ins> element can be used for the opposite purpose: to indicate text that has been added to the document.

Global attributes

Global attributes are attributes common to all HTML elements. They can be used on all elements, though they may have no effect on some elements.

  • accesskey: Specifies a shortcut key to activate/focus an element

  • class: Specifies one or more class names for an element (refers to a class in a style sheet)

  • contenteditable: Specifies whether the content of an element is editable or not

  • data-*: Used to store custom data private to the page or application

  • dir: Specifies the text direction for the content in an element

  • draggable: Specifies whether an element is draggable or not

  • hidden: Specifies that an element is not yet or is no longer relevant

  • id: Specifies a unique id for an element

  • lang: Specifies the language of the element's content

  • spellcheck: Specifies whether the element is to have its spelling and grammar checked or not

  • style: Specifies an inline CSS style for an element

  • tabindex: Specifies the tabbing order of an element

  • title: Specifies extra information about an element

  • translate: Specifies whether the content of an element should be translated or not.

You can learn more about all the other global attributes here in detail. Now in upcoming blog, we look into some of the other HTML elements till then