Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Attributes

0/1

HTML Paragraphs

0/1

HTML Formatting

0/1

HTML Comments

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML Symbols

0/1
Text lesson

Close All HTML Elements

In HTML, it’s not mandatory to close all elements (e.g., the <p> element).

Nevertheless, we highly recommend closing all HTML elements, following this syntax:

Good:

<section>
  <p>This is a paragraph.</p>
  <p>This is a paragraph.</p>
</section>

Bad:

<section>
  <p>This is a paragraph.
  <p>This is a paragraph.
</section>

Use Lowercase Attribute Names

While HTML permits mixing uppercase and lowercase letters in attribute names, it’s advisable to opt for lowercase names. Here’s why:

  1. Mixing uppercase and lowercase names can appear inconsistent.
  2. Developers typically prefer using lowercase names for consistency.
  3. Lowercase names offer a cleaner aesthetic.
  4. Writing in lowercase is generally easier and more intuitive.Good:
<a href=”https://www.code7school.com/html/”>Visit our HTML tutorial</a>

Bad:

<a HREF=”https://www.code7school.com/html/”>Visit our HTML tutorial</a>

Always Quote Attribute Values

Although HTML permits attribute values without quotes, it’s advisable to use quoted attribute values. Here’s why:

  • Developers typically enclose attribute values in quotes for consistency.
  • Quoted values enhance readability.
  • Quotes are necessary when the value contains spaces.

Good:

<table class=”striped”>

Bad:

<table class=striped>

Very bad:

This approach won’t function as expected due to the presence of spaces in the value.

<table class=table striped>

Always Specify alt, width, and height for Images

It’s crucial to always include the alt attribute for images. This attribute serves as vital descriptive text if the image fails to display for any reason.

Additionally, it’s advisable to define the width and height of images. Doing so minimizes flickering by allowing the browser to allocate space for the image before loading it.

Good:

<img src=”html5.gif” alt=”HTML5″ style=”width:128px;height:128px”>

Bad:

<img src=”html5.gif”>