04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

more about markup and tags<br />

Q: So <strong>HTML</strong> is just a bunch of tags<br />

that I put around my text?<br />

A: For starters. Remember that <strong>HTML</strong><br />

stands for HyperText Markup Language, so<br />

<strong>HTML</strong> gives you a way to “mark up” your<br />

text <strong>with</strong> tags that tell the browser how your<br />

text is structured. But there is also the<br />

HyperText aspect of <strong>HTML</strong>, which we’ll talk<br />

about a little later in the book.<br />

Q: How does the browser decide how<br />

to display the <strong>HTML</strong>?<br />

A: <strong>HTML</strong> tells your browser about<br />

the structure of your document: where the<br />

headings are, where the paragraphs are,<br />

what text needs emphasis, and so on.<br />

Given this information, browsers have builtin<br />

default rules for how to display each of<br />

these elements.<br />

But, you don’t have to settle for the default<br />

settings. You can add your own style and<br />

formatting rules <strong>with</strong> <strong>CSS</strong> that determine<br />

font, colors, size, and a lot of other<br />

characteristics of your page. We’ll get back<br />

to <strong>CSS</strong> later in the chapter.<br />

Q: The <strong>HTML</strong> for the <strong>Head</strong> <strong>First</strong><br />

Lounge has all kinds of indentation and<br />

spacing, and yet I don’t see that when it<br />

is displayed in the browser. How come?<br />

A: Correct, and good catch. Browsers<br />

ignore tabs, returns, and most spaces in<br />

<strong>HTML</strong> documents. Instead, they rely on<br />

your markup to determine where line and<br />

6 Chapter 1<br />

there are no<br />

Dumb Questions<br />

paragraph breaks occur.<br />

So why did we insert our own formatting if<br />

the browser is just going to ignore it? To<br />

help us more easily read the document when<br />

we’re editing the <strong>HTML</strong>. As your <strong>HTML</strong><br />

documents become more complicated,<br />

you’ll find a few spaces, returns, and tabs<br />

here and there really help to improve the<br />

readability of the <strong>HTML</strong>.<br />

Q: So there are two levels of<br />

headings, and a subheading ?<br />

A: Actually there are six, <br />

through , which the browser typically<br />

displays in successively smaller font sizes.<br />

Unless you are creating a complex and<br />

large document, you typically won’t use<br />

headings beyond .<br />

Q: Why do I need the tag?<br />

Isn’t it obvious this is a <strong>HTML</strong> document?<br />

A: The tag tells the browser<br />

your document is actually <strong>HTML</strong>. While<br />

some browsers will forgive you if you omit<br />

it, some won’t, and as we move toward<br />

“industrial strength <strong>HTML</strong>” later in the book,<br />

you’ll see it is quite important to include<br />

this tag.<br />

Q: What makes a file an <strong>HTML</strong> file?<br />

A: Basically an <strong>HTML</strong> file is a simple<br />

text file. Unlike a word processing file, there<br />

is no special formatting embedded in it. By<br />

convention we add a “.html” or “.htm” (on<br />

systems that only support three letter file<br />

extensions) to the end of the file name to<br />

give the operating system a better idea of<br />

what the file is. But, as you’ve seen, what<br />

really matters is what we put inside the file.<br />

Q: Markup seems silly. What-yousee-is-what-you-get<br />

applications have<br />

been around since, what, the ‘70s? Why<br />

isn’t the Web based on a format like<br />

Microsoft Word or a similar application?<br />

A: The Web is created out of text files<br />

<strong>with</strong>out any special formatting characters.<br />

This enables any browser in any part of<br />

the world to retrieve a Web page and<br />

understand its contents. You’ll see that<br />

on the Web, in many ways <strong>HTML</strong> is more<br />

powerful than using a proprietary document<br />

format.<br />

Q: Is there any way to put comments<br />

to myself in <strong>HTML</strong>?<br />

A: Yes, if you place your comments<br />

in between the browser will<br />

totally ignore them. Say you wanted to write<br />

a comment “Here’s the beginning of the<br />

lounge content”. You’d do that like this:<br />

<br />

Notice that you can put comments on<br />

multiple lines. Keep in mind anything you<br />

put between the “”, even<br />

<strong>HTML</strong>, will be ignored by the browser.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!