Book Image

Web Development with Jade

By : Sean Lang
Book Image

Web Development with Jade

By: Sean Lang

Overview of this book

Table of Contents (16 chapters)

Significance of whitespace


Rather than using opening/closing tags to delimit the start/end of blocks, Jade uses indentation. This can be a little strange if you're used to languages where whitespace doesn't matter (such as JS, CSS, and of course HTML). However, it does have the benefit of forcing you to have good indentation, preventing horrible formatting as illustrated in the following code (which is a perfectly valid HTML):

<!DOCTYPE html>
<html><head><title>An Example</title></head>
<body><h1>Horrible Formatting</h1>
<p>Never write HTML like this, it is <i>really</i> hard to read</p>
</body></html>

Also, whitespace significance prevents stupid errors like the following:

<i>notice the order of the <b>closing tags</i></b>

Now onto how it actually works:

Each level of indentation (the rectangles outlined with dashed lines) creates a new block (the pastel-colored sections) out of...