Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Web Development with Jade

You're reading from   Web Development with Jade Knowing Jade makes life simpler and more productive for web developers, and this book will teach you the language concisely and thoroughly using lots of practical examples and best practices for a solid grounding.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher
ISBN-13 9781783286355
Length 80 pages
Edition Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Sean Lang Sean Lang
Author Profile Icon Sean Lang
Sean Lang
Arrow right icon
View More author details
Toc

Shorthands


IDs and classes

IDs and classes are both pretty common attributes, so Jade gives us a shorthand method for writing them. This is similar to the way CSS selectors are written. An example of this is as follows:

Jade

HTML

p#hello Hello Word!
<p id="hello">Hello Word!</p>
p#hello.world
<p id="hello" class="world"></p>

Pretty familiar, eh? IDs are just prefixed with a # (pound symbol) and classes are prefixed with . (a period). These may be put in any order after the tag name with any number of classes.

Automatic div

Because the div tags are used so frequently, Jade offers a shorthand way for writing them; by omitting the tag, Jade assumes you want to use a div tag; therefore, the following code:

Jade

HTML

div#hello Hello Word!
<div id="hello">
Hello Word!
</div>

It can also be rewritten as:

Jade

HTML

#hello Hello Word!
<div id="hello">
Hello Word!
</div>

However, this is possible only as long as there is an ID and/or class where the tag name...

You have been reading a chapter from
Web Development with Jade
Published in: Mar 2014
Publisher:
ISBN-13: 9781783286355
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime