This XHTML document is our first full example document created within this book. We will be creating additional documents to provide you with working examples of the concepts presented in upcoming chapters.
The document now has something other than background to display! The basic2.html file is shown in a Web browser in Figure 3.7.This page provides examples of two different types of links. The first is a link out to another page. This link is to the Sybex Web site.
The second link is to another file on this imaginary Web site. This link is to Page Two of our site.
You arrived at this page from a hyperlink on the links.html page.
Aside from linking from one page to another, you can link from one section of a page to another, especially useful in long pages. Let's link to where we'll try it out.
Now I'll create a long page, one that will extend beyond the lower boundary of your browser window—if you can see the entire file, resize your browser so that you can't see the second heading. To fill the page, I've used a traditional passage of Latin text, as shown in Listing 4.3. Listing 4.3: page3.htmlLorem ipsem dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Multum in parvo sed non in adipisce. Non angli sed angeli. Amet sed tibi nunc dimittis ut donae ferente.
Now we want to link further down the page.
Lorem ipsem dolor sit amet sed tibi nunc dimittis ut donae
page 44
Effective Web Design ferente. Multum in parvo sed non in adipisce elim van dutter. Dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Multum in parvo sed non in adipisce. Non angli sed angeli. Amet sed tibi nunc dimittis ut donae ferente.
Lorem ipsem dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Multum in parvo sed non in adipisce. Non angli sed angeli. Amet sed tibi nunc dimittis ut donae ferente.
Lorem ipsem dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Multum in parvo sed non in adipisce. Non angli sed angeli. Amet sed tibi nunc dimittis ut donae ferente.
Lorem ipsem dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Dolor sit amet sed tibi nuncdimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Multum in parvo sed non in adipisce. Non angli sed angeli. Amet sed tibi nunc dimittis ut donae ferente.
Lorem ipsem dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Dolor sit amet sed tibi nunc dimittis ut donae ferente. Multum in parvo sed non in adipisce elim van dutter. Multum in parvo sed non in adipisce. Non angli sed angeli. Amet sed tibi nunc dimittis ut donae ferente.
You'll notice the anchor tag around the phrase "further down" has a URL with a hash mark—the # symbol, commonly referred to in the United States as the "pound sign." The tag is shown here: further down The tag instructs the browser to go to a specifically marked section on the same page. Here, that point is the h2 element, which contains the anchor element . The code is shown here:and the corresponding closing tag. The data contained within the tags is displayed exactly as it is laid out in the source XHTML file. Line breaks and multiple-space characters (to produce white space) are preserved. In order to keep the absolute formatting of the data, browsers will use a fixed-width font. The default font used in both Internet Explorer and Navigator on a Windows platform is Courier New.
The first example is the use of the specific element for italic text. XHTML authors should trend toward using the emphasis element instead.
Next is the element just for bold text. XHTML authors should begin to use the strong emphasis element instead.
Additional font styling includes the use of teletype text. The teletype text element is displayed in a monospaced (fixed-width) font.
Other options include using a big text element or small text; the strike element that lets the reader know that text has been struck through, as is often seen in legal documents; and the underline element, u, to show text that has been underlined.
I often use the ÷ sign.
TipI often use the ÷ sign.
I often use the ÷ sign.
Tip"I love XHTML."
Tip5 <
5 > 3
The & symbol is frequently escaped by using the & entity.
This example is a bit trickier than others you've seen. Note that the second ampersand is escaped and then immediately followed by amp;. Viewed in a browser, & will render "&." Try it out for yourself.Name | Age |
Dave | 33 |
Ann | 34 |
Name | Age |
Dave | 33 |
Ann | 34 |
Name | Age |
Dave | 33 |
Ann | 34 |
X | O | |
O | X | O |
X |
Name | Type | Breed |
Dizzy | Cat | Grey Tabby |
Bubba | Dog | Pembroke Welsh Corgi |
Name | Type | Breed |
Dizzy | Cat | Grey Tabby |
Bubba | Dog | Pembroke Welsh Corgi |
Name | Type | Breed | Traits |
Dizzy | Cat | Grey Tabby | quiet, loves to lay on paper |
Bubba | Dog | Pembroke Welsh Corgi | hyperactive, attention span of a gnat, loves to play fetch with his Koosh ball, drinks water out of the swimming pool |
Name | Age |
Dave | 33 |
Ann | 34 |
Name | Age |
Dave | 33 |
Ann | 34 |
Name | Dizzy | Bubba |
Type | Cat | Dog |
Breed | Grey Tabby | Pembroke Welsh Corgi |
Traits | quiet, loves to lay on paper | hyperactive, attention span of a gnat, loves to play fetch with his Koosh ball, drinks water out of the swimming pool |
Name | Age |
Dave | 33 |
Ann | 34 |
Name | Age |
August 17, 1996 | |
Dave | 33 |
Ann | 34 |
Name | Age |
August 17, 1996 | |
Dave | 33 |
Ann | 34 |
frame 1, quadrant 1
frame 2, quadrant 2
frame 3, quadrant 3
frame 4, quadrant 4
A no-frames version is available here.
page 95
Effective Web Design
The body container presents the user with the single sentence and link shown in Figure 6.6.
Figure 6.6: Index.html as seen in a nonframes browser (NCSA Mosaic 3 for Windows 95) You'll notice that the link provided within index.html (Listing 6.9) is to main.html (listing 6.10), the same file used as the original src value of the second frame. The main.html file is where the noframes content will be presented, as shown here in Listing 6.10. Listing 6.10: main.html
...the navigational content from nav.html here...
...the original content found in the main.html document here... Although I haven't yet created the main.html file content, you should know that the addition of the noframes element to hold the navigational content from the nav.html frame (in case the user is unable to use frames) will not affect anything else in the document. The noframes container is simply inserted immediately below the opening body tag and before any other XHTML markup. Figure 6.6 displays this short file in a nonframes browser. Looks like a regular XHTML page, doesn't it? That's the idea. The move from the framed content to a nonframes display should be as transparent as possible for the user without a frames-capable browser. The noframes example used in Listing 6.10 provides a simple transition between Tip framed and unframed content. Designers who choose a more complex framed presentation—such as nested framesets or more than two or three frames in a single frameset—may be required to provide a full second set of XHTML pages for
page 96
Effective Web Design nonframed presentation. At that point, a designer should conduct a cost-benefit analysis to evaluate how worthwhile such a presentation is compared to the cost of providing two complete versions of the site. Depending on the type of site being created, accessibility issues may also come into play—whether as the right thing to do to meet federal standards about Web-site accessibility. For more information on accessible design methods, see Chapter 20. The Inline Frame An inline frame—the iframe element—can be thought of as an image or other object that is inserted into an XHTML document. The object is presented in the specific space that you specify, and text and other elements can flow around it. The attributes for the iframe element include most of those for the frame element. (See the section "The frame Element" earlier in this chapter.) The only exception is the noresize attribute, which cannot be used in iframe. Additional attributes include width and height, which are used the same way as they are for setting aside space for images. (See the section "Image Dimensions: width and height" in Chapter 4.) You can use width and height values instead of noresize; the object can't be modified later. You can name the inline frame as well as determine its border, margin, and scrolling properties. As with frame, the information to be displayed in the inline frame is assigned in the src attribute. It can be an XHTML file or any other file that would ordinarily be viewed through a link. Here's a short example in Listing 6.11. Listing 6.11: Displaying Text in an Inline Frame The XHTML markup in Listing 6.11 displays the contents of info.html, shown in Listing 6.12, in an inline frame, as seen in Figure 6.7.
Figure 6.7: An inline frame as seen in IE 5 Listing 6.12: info.html
page 97
Effective Web Design
This content is being presented within the inline frame.
The newly modified main.html file is shown in Listing 6.13. It was modified to accept an inline frame; info.html is inserted into the frame. Listing 6.13: main.html...the original main.html document here...
Next is the inline frame.
Other content can flow around it, as shown here. The text within the info.html file was set to the color blue intentionally, to show off that text as being specific to the inline frame.
This is normal text. On this browser, the default font is Times New Roman.
This line has some emphasized text, which appears in a purple color and the font Courier.
This is normal text. On this browser, the default font is Times New Roman.
This line has some emphasized text, which appears in a purple color and the Courier font.
This time, we'll use strong emphasis defined in-line for a red color.
This file was created using an external style sheet named mystyle.css. The style sheet determined the color and justification of the heading, the font face, the alignment of this paragraph, and the application of color to the emphasis tag.
Many style rules are inherited. The emphasized word in the previous sentence inherited the red coloring of the paragraph text.
Note that the first heading, an h1 element, is colored black and centered. It did not inherit the green color of the body because we specifically declared a rule for it.
The second heading, however, written with an h2 element, did inherit the green coloring as a child element of body, since no other rules were defined for h2 elements.
This sentence contains an underlined word.
This implementation necessitates a bit more typing for you when applying styles to single words or phrases, as was done here. However, the W3C's decision to deprecate the underline and strikethrough containers keeps style elements consistently within the style-sheet realm instead of within XHTML.What type of Internet connection do you use?
modemHow many hours a week do you spend online?
Because the select container and its contents are all part of the control, the select element contains the name attribute. The value of the control is determined by which option is selected when the form is processed. The foregoing simple select control is displayed as a drop-down menu, as shown here.Please tell us which Web sites are your favorites:
As with all form controls, the textarea must be named. The attributes rows and cols define the borders of the input area in terms of the number of lines high—rows—and the number of single-spaces wide—columns. The textarea control also allows you to prompt the user by placing some text into the field. Anything contained between the opening and closing textarea tag will be displayed inside the field, as seen in Figure 8.6 and in the lines that follow:Name:
Email:
Telephone:
Name: | |
Email: | |
Telephone: |
Please tell us where you use the Web:
home
work
both
What kind of connection do you have to the Web? modem ISDN DSL cable LAN
The radio buttons display on a single line because the input element does not inherently generate a line or paragraph break. Until the browser reaches a new p or br element (or a block-level element that implies one), it will continue to place the elements inline until it's forced to wrap at the right edge of the available window. Please tell us where you use the Web: home work both |
What kind of connection do you have to the Web? modem ISDN DSL cable LAN |