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

HTML Comments

Concise comments should be single-lined, such as:

<!– This is a comment –>

Multi-line comments should be formatted as follows:

<!– 
  This is a long comment example. This is a long comment example.
  This is a long comment example. This is a long comment example.
–>

Long comments are more readable when they are indented with two spaces for clarity.

Using Style Sheets

Simplify linking to style sheets by omitting the type attribute.

<link rel=”stylesheet” href=”styles.css”>

Short CSS rules can be compressed for brevity, like so:

p.intro {font-family:Verdana;font-size:16em;}

For lengthy CSS rules, it’s advisable to spread them across multiple lines:

body {
  background-color: lightgrey;
  font-family: “Arial Black”, Helvetica, sans-serif;
  font-size: 16em;
  color: black;
}

Ensure consistency in CSS formatting:

  • Begin each rule with the opening bracket on the same line as the selector, preceded by a single space.
  • Indent the properties and values with two spaces.
  • Conclude each property-value pair with a semicolon, even the last one.
  • Use quotes around values only when necessary, such as when they contain spaces.
  • Conclude each rule with the closing bracket on a new line, without leading spaces.

Loading JavaScript in HTML

Simplify the syntax for loading external scripts by omitting the type attribute.

<script src=”myscript.js”>

Accessing HTML Elements with JavaScript

Employing messy HTML code may lead to JavaScript errors.

These two JavaScript statements yield distinct outcomes:

Example

getElementById(“Demo”).innerHTML = “Hello”;

getElementById(“demo”).innerHTML “Hello”;