04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

What is XML?<br />

Okay, we’re going to take a big step back, for a page or two, and look at XML (not to be<br />

confused <strong>with</strong> X<strong>HTML</strong>). This is going to be a fast ride, so hang on...<br />

Let’s use <strong>HTML</strong> for comparison. With <strong>HTML</strong> you’re basically told what elements you<br />

can and can’t use, right? So, if you want to just make up an element, like , to<br />

wrap around content, you can’t do it, can you? Ah, but <strong>with</strong> XML, you can. If fact, you<br />

can invent totally new markup languages using XML. Let’s look at an example:<br />

Here’s the root element. It’s not called , it’s called ,<br />

since this is the XML for a recipe. Notice it has some extra attributes<br />

in it, which you’ve never seen on an element in <strong>HTML</strong>.<br />

<br />

<strong>Head</strong> <strong>First</strong> Lounge Iced Tea<br />

A brisk iced tea <strong>with</strong> a bit of a kick. We<br />

serve this all day long.<br />

<br />

<br />

water<br />

black tea<br />

earl grey tea<br />

ice<br />

<br />

<br />

<br />

Boil one cup of water in a pan, remove pan, and<br />

add tea. Let steep for five minutes.<br />

Add ice to a pitcher, then add tea,<br />

then 5 cups cold water.<br />

Mix well and serve. Give tea a<br />

quick shake in a shaker for an<br />

extra touch.<br />

<br />

<br />

Other than the element names, the way the<br />

elements look and are used is just like <strong>HTML</strong><br />

(opening tags, closing tags, and so on).<br />

moving to xhtml<br />

Wow, look at these tags. The<br />

s and s are all gone, and<br />

instead we’ve got , ,<br />

, s,<br />

, and so on.<br />

Just by looking at the<br />

element names you can<br />

tell this is a recipe.<br />

This empty element looks<br />

a little strange. We’ll come<br />

back to that in a bit.<br />

? brain<br />

power<br />

Think about how you would<br />

create a Web page using <strong>HTML</strong><br />

to represent the recipe. How<br />

would that be different from<br />

using XML?<br />

you are here 267

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

Saved successfully!

Ooh no, something went wrong!