Skip to Main Content
Creating a Website: The Missing Manual, 3rd Edition
book

Creating a Website: The Missing Manual, 3rd Edition

by Matthew MacDonald
May 2011
Beginner content levelBeginner
584 pages
17h 42m
English
O'Reilly Media, Inc.
Content preview from Creating a Website: The Missing Manual, 3rd Edition

HTML Elements for Basic Text

As you learned in Chapter 2, you need to know two things about every new element you meet. To use an element correctly, you need to answer these two questions:

  • Is it a container element or a standalone element?

  • Is it a block element or an inline element?

The first question tells you something about the syntax you use when you add an element to a document. Container elements (like the <b> element that boldfaces text) require a start and end tag, with the content sandwiched in between. Standalone elements (like the <img> element that inserts an image into a page) use a single, all-in-one tag. If standalone elements need additional information, like the location of an image file, you supply it using attributes.

The second question tells you something about where you can place an element. Block elements (like the <p> element) go inside the main <body> element or within other block elements of a page. When you start building the overall structure of your page, you always begin with block elements. Inline elements (like the <img> element) have to go inside block elements. Inline elements don’t make sense when they’re on their own, floating free of any container.

Tip

To quickly check whether an element is a container or standalone element and to see if it’s a block or inline element, check the HTML reference in Appendix A.

Block elements also have an effect on the spacing of your content. Essentially, each block element defines a chunk of content. When you end a block ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Creating a Website: The Missing Manual, 4th Edition

Creating a Website: The Missing Manual, 4th Edition

Matthew MacDonald
Learn to Build a Website

Learn to Build a Website

Cassidy Williams, Camryn Williams

Publisher Resources

ISBN: 9781449306823Supplemental ContentErrata Page