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.

character entities are for special characters<br />

114 Chapter 3<br />

I was just creating a Web<br />

page explaining everything I was<br />

learning from this book, and I wanted<br />

to mention the element inside<br />

my page. Isn’t that going to mess up<br />

the nesting? Do I need to put double<br />

quotes around it or something?<br />

You’re right, that can cause problems.<br />

Because browsers use < and > to begin and end tags, using<br />

them in the content of your <strong>HTML</strong> can cause problems.<br />

But, <strong>HTML</strong> gives you an easy way to specify these and other<br />

special characters using a simple abbreviation called a character<br />

entity. Here’s how it works: for any character that is considered<br />

“special” or that you’d like to use in your Web page, but that<br />

may not be a typeable character in your editor (like a copyright<br />

symbol), you just look up the abbreviation and then type it into<br />

your <strong>HTML</strong>. For example, the > character’s abbreviation is<br />

&gt; and the < character’s is &lt;.<br />

So, say you wanted to type “The element rocks.” in<br />

your page. Using the character entities, you’d type this instead:<br />

The &lt;html&gt; element rocks.<br />

Another important special character you should know about<br />

is the & character. If you’d like to have an & in your <strong>HTML</strong><br />

content, use the character entity &amp; instead of the &<br />

character itself.<br />

So what about the copyright symbol? And all those other<br />

symbols and foreign characters? You can look common ones<br />

up at this URL:<br />

http://www.w3schools.com/tags/ref_entities.asp<br />

or, for a more exhaustive list, use this URL:<br />

http://www.unicode.org/charts/

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

Saved successfully!

Ooh no, something went wrong!