HTML5:  Popular Semantics

HTML5: Popular Semantics

·

3 min read

Tags instead of CSS

  • <b> & <strong>: Used for bold and important text respectively.

  • <i> & <em>: Used for italic and emphasized text respectively.

  • Diff: 2 tags strong & em thể hiện sự quan trọng hơn thay vì chỉ làm thay đổi như b & i

  • <mark>: Highlights or marks specific text.

  • <center>: Centers text horizontally (instead of using CSS text-align: center).

  • <del> - Deleted text instead of line-through (text-decoration css)

  • <ins> - Inserted text instead of underline (text-decoration css)

  • <abbr> - Inserted text instead of underline dotted (text-decoration css)

  • <small>, <sub>, <sup>: Used for smaller text, subscript text, and superscript text respectively.

  • Diff: align center, up, down

  • <blockquote> & <q>: Used for quotations and short quotations respectively.

  • <template>: Represents a document fragment that can be cloned and inserted into the document.

Semantic HTML Layout

  • <main>: Represents the main content of a document.

  • <aside>: Represents content that is tangentially related to the main content.

  • <section>: Represents a standalone section of content.

  • <article>: Represents a self-contained composition that can be independently distributed or syndicated.

  • <footer>: Represents the footer of a document or a section.

  • <address>: Represents contact information for the nearest <article> or <body> ancestor.

  • <time>: Represents either a specific time or a range of time.

  • <cite>: Represents the title of a work (e.g., a book, a paper, an album, etc.).

Specific Controls

  • <dialog>: Represents a dialog box or a window.

  • <select>: Represents a control that allows users to select options from a list.

  • <input>: Represents a control for user input, with various types such as button, range, calendar, etc.

Collapse & Extend

  • <details> & <summary>: Used together to create a collapsible section with a summary.

Content-script

  • <code>: Represents a fragment of computer code.

Freestyle Text

  • <pre>: Represents preformatted text, preserving spaces and line breaks.

Combining Autocomplete & Select

  • <datalist>: Specifies a list of pre-defined options for an <input> element.

Form Title

  • <fieldset> & <legend>: Used together to group related form elements and provide a title.

Coordinate Action

  • <map>: Specifies an image map, which links regions of an image to actions.

Progress View

  • <meter> & <progress>: Used to represent progress, such as the completion of a task.

Fallback for Non-JavaScript Browsers

  • <noscript>: Represents alternate content to be displayed when a browser doesn't support JavaScript or has it disabled.

Dynamic External Resources

  • <object>: Represents an external resource, such as an embedded iframe, image, video, or audio.

Default URL & Target

  • <base> & <basefont>: Used to specify a default URL and a default target for all links on a page.