10.07.2015 Views

Building the User Interface by Using HTML5: Text, Graphics ... - server

Building the User Interface by Using HTML5: Text, Graphics ... - server

Building the User Interface by Using HTML5: Text, Graphics ... - server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

24 | Lesson 2Figure 2-1A hyperlink is <strong>the</strong> result of<strong>the</strong> anchor element using <strong>the</strong>href attributeLICENSED PRODUCT NOT FOR RESALETwo of <strong>the</strong> most common uses of attributes are to create hyperlinks and to insert simplegraphics. You’ll learn how to work with graphics later in this lesson. <strong>HTML5</strong> includes severalglobal attributes, which you can use with any <strong>HTML5</strong> element. Examples of global attributesinclude id, lang, and class, among many o<strong>the</strong>rs.NESTING ELEMENTSHow a Web browser displays your HTML depends on <strong>the</strong> way you combine elements, <strong>the</strong>irattributes (if any), and content. When two or more elements apply to <strong>the</strong> same block of text,you should nest tag pairs appropriately so that <strong>the</strong>y do what you intended. Nesting means toplace one element inside ano<strong>the</strong>r. Here’s an example of correct nesting:Make sure your pet has plenty of fresh waterduring hot wea<strong>the</strong>r.In this case, we want <strong>the</strong> words “fresh water” to stand out so <strong>the</strong>y are italicized and bolded <strong>by</strong>using <strong>the</strong> and tags. If you placed <strong>the</strong> end tag after <strong>the</strong> end tag (shownbelow), <strong>the</strong> words “fresh water during hot wea<strong>the</strong>r” would appear bold but only “fresh water”would be italicized. It would look awkward, as shown in Figure 2-2.Make sure your pet has plenty of fresh waterduring hot wea<strong>the</strong>r.Figure 2-2Incorrectly nesting tagsThe rule for nesting is that nested tags must be closed before <strong>the</strong>ir parent tags. Looking backat <strong>the</strong> correct example, notice that <strong>the</strong> paragraph element opens first, followed <strong>by</strong> <strong>the</strong> italicelement, and <strong>the</strong>n <strong>the</strong> font element. Then <strong>the</strong> bold element closes, followed <strong>by</strong> <strong>the</strong> italic element,and finally <strong>the</strong> paragraph element. The italic and bold elements are completely nestedwithin <strong>the</strong> paragraph element.UNDERSTANDING ENTITIESAn entity is a special character, such as <strong>the</strong> dollar symbol, <strong>the</strong> registered trademark (a capitalR within a circle), and accented letters. The process of incorporating entities in a Web page is

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

Saved successfully!

Ooh no, something went wrong!