HTML Tutorials - Learn HTML
Craft the Web Learn HTML5 and CSS.
Wednesday, 17 April 2024
Wednesday, 21 February 2024
Must Do Professional Courses in Dubai
Are you looking to enhance your career prospects and stay ahead in today's competitive job market? Look no further than Rolla Academy in Dubai, your premier destination for professional development. Our comprehensive range of courses in Dubai is designed to equip you with the skills and knowledge needed to excel in your chosen field. Whether you're looking to advance in your current career or switch to a new industry, we have the perfect course for you. Let's explore the must-do professional courses offered by Rolla Academy in Dubai:
Digital Marketing Certification:
- Master the art of digital marketing with our comprehensive certification course.
- Learn essential skills such as SEO, social media marketing, email marketing, and content creation.
- Gain hands-on experience through real-world projects and case studies.
- Prepare yourself for exciting career opportunities in the fast-paced world of digital marketing.
Project Management Professional (PMP) Certification:
- Become a certified project management professional and take your career to new heights.
- Learn industry best practices and techniques for successful project management.
- Acquire essential skills in project planning, execution, monitoring, and control.
- Prepare for the PMP certification exam with confidence and become a sought-after project manager.
Graphic Design Essentials:
- Unleash your creativity and become a proficient graphic designer.
- Learn essential design principles, tools, and techniques using industry-standard software.
- Master the art of creating logos, brochures, banners, and other visual elements.
- Build a stunning portfolio to showcase your skills and attract potential clients or employers.
Certified Human Resource Management Professional (CHRMP):
- Take your HR career to the next level with our CHRMP certification course.
- Gain a deep understanding of HR principles, practices, and strategies.
- Learn essential skills such as recruitment, training, performance management, and employee relations.
- Become a trusted HR professional and contribute to the success of any organization.
Financial Modeling and Valuation:
- Develop advanced financial modeling skills and excel in the world of finance.
- Learn to build dynamic financial models and conduct in-depth financial analysis.
- Master valuation techniques used in mergers and acquisitions, investment banking, and corporate finance.
- Prepare yourself for lucrative career opportunities in finance and investment management.
At Rolla Academy - Training Instiute in Dubai, we are committed to providing high-quality education and training that empowers individuals to achieve their professional goals. Whether you're a recent graduate, seasoned professional, or aspiring entrepreneur, our courses are tailored to meet your needs and aspirations. Don't wait any longer – enroll in one of our must-do professional courses today and take the first step towards a successful and rewarding career journey.
Certified Public Accountant (CPA)
Offered by: American Institute of CPAs (AICPA)
Description: CPA certification is essential for accounting professionals, covering areas such as financial accounting, taxation, auditing, and business ethics.
Benefits: Opens doors to diverse career opportunities in accounting and finance, increases credibility, and boosts earning potential.
Certified Human Resource Professional (CHRP)
Offered by: Society for Human Resource Management (SHRM)
Description: CHRP certification validates your expertise in human resource management, including areas such as recruitment, employee relations, performance management, and HR strategy.
Benefits: Enhances HR knowledge and skills, demonstrates commitment to professional development, increases job opportunities in HR management.
Certified Digital Marketing Professional (CDMP)
Offered by: Digital Marketing Institute (DMI)
Description: CDMP certification covers various aspects of digital marketing, including SEO, social media marketing, email marketing, content marketing, and analytics.
Benefits: Provides in-demand digital marketing skills, enhances career prospects in the digital marketing field, increases marketability to employers.
Certified Information Systems Security Professional (CISSP)
Offered by: International Information System Security Certification Consortium (ISC)²
Description: CISSP certification is for information security professionals, covering areas such as security and risk management, asset security, cryptography, and network security.
Benefits: Validates expertise in information security, enhances career opportunities in cybersecurity, increases earning potential.
Certified Supply Chain Professional (CSCP)
Offered by: Association for Supply Chain Management (ASCM)
Description: CSCP certification focuses on supply chain management, covering areas such as logistics, operations, procurement, and inventory management.
Benefits: Demonstrates expertise in supply chain management, enhances career prospects in logistics and supply chain roles, increases earning potential.
Certified Financial Analyst (CFA)
Offered by: CFA Institute
Description: CFA certification is for finance professionals, covering areas such as investment management, financial analysis, portfolio management, and ethics.
Benefits: Enhances expertise in finance and investment management, opens doors to prestigious finance roles, increases credibility in the finance industry.
Certified Information Technology Professional (CITP)
Offered by: American Institute of CPAs (AICPA)
Description: CITP certification is for IT professionals with a focus on technology assurance, information management, and consulting services.
Benefits: Validates expertise in IT management and consulting, enhances career prospects in IT leadership roles, increases credibility with clients and employers.
These professional courses in Dubai offer valuable skills and certifications that can significantly enhance your career prospects and professional development in various fields. Consider choosing the course that aligns with your career goals and aspirations.
Tuesday, 20 February 2024
CCNA Training in Dubai - Cisco Certified Network Administrator
https://rollaacademydubai.com/
Rolla Academy is one the UAE’s leading certification training providers in the field of IT, Programming, Networking, Accounting, Designing and Management.
MCSA and MCSE training as well: https://rollaacademydubai.com/courses/cisco-training-ccna/
GMB Listing:
https://www.google.com/search?source=hp&ei=m2nqXfvFDZKfmgfSu7iwBQ&q=rolla+academy&oq=rolla+a&gs_l=psy-ab.3.0.0j0i10j0j0i10l7.1441.2554..4010...0.0..0.133.773.0j7......0....1..gws-wiz.......0i131.E8KdDoGcU3I
Serving Areas:
https://www.google.com/maps/d/u/0/viewer?mid=1QeGhxmT-jfKAHrFSQdcGsi9e1LnGMjBl&ll=25.256774429456406%2C55.29576999999995&z=10
Name:
Rolla Academy Dubai
Address:
201, Al Tawhidi Building - 2 Al Mankhool Rd - Dubai - United Arab Emirates
Phone Number:
+971 50 780 1081
Why Choose Our CCNA Training Institute?
Hands-On Learning: At our institute, we believe in learning by doing. That's why our CCNA course focuses on practical, real-world training in our state-of-the-art lab facilities. You'll have the opportunity to work with industry-standard equipment and technologies under the guidance of certified trainers.
Certified Trainers: Our trainers are seasoned professionals with extensive experience in network administration and Cisco technologies. They are Cisco-certified experts who are dedicated to providing you with the highest quality training and support throughout your learning journey.
Practical Approach: We understand that theory alone is not enough to master networking concepts. That's why our CCNA course emphasizes practical, hands-on training. You'll learn how to configure routers and switches, troubleshoot network issues, and implement security measures in a real-world environment.
Comprehensive Curriculum: Our CCNA course covers all the essential topics required for certification, including network fundamentals, routing and switching, LAN and WAN technologies, network security, and more. You'll gain a deep understanding of Cisco networking technologies and prepare yourself for the CCNA certification exam.
Career Opportunities: With CCNA certification, you'll open doors to exciting career opportunities in network administration, cybersecurity, cloud computing, and more. The demand for certified network administrators is on the rise, and our CCNA training institute will help you stand out in the competitive job market.
Don't miss this opportunity to kickstart your career in network administration with our CCNA training institute in Dubai. Enroll today and take the first step towards becoming a certified Cisco network administrator. Let's master networking together!
Wednesday, 27 May 2015
Formatting Text In HTML
Text
Although the modern-day Web is a haven of multimedia, text is still vitally important. Only through text can some messages be succinctly communicated. Even then, diversity in text can help further clarify a message. For example, emphasizing one word with bold or italic font can change the tone and meaning of a sentence. This chapter discusses how to format elements inside of block elements (words or sentences inside of paragraphs). Web Design Course Dubai Methods of Text Control There are various means to control the look and formatting of text in your documents. It should come as no surprise that the more direct methods—<font> tags and the like—have been deprecated in favor of CSS controls in HTML 4.01 and XHTML. The following sections cover the various means possible for historical and completeness purposes.
Tip
Although it is sometimes easier to drop a direct format-
ting tag into text, resist the urge and use styles instead.
Your documents will be more flexible and more stan-
dards compliant.
The <font> tag
The <font> tag enables you to directly affect the size and color of text. Intuitively, the size attribute is used to change the size of text, and the color attribute is used to change the color. The size of the text is specified by a number, from 1-7, or by signed number (also 1-7). In the latter case, the size change is relative to the size set by the <basefont> tag. The <basefont> tag has one attribute, size, which can be set to a number, 1-7.
Note Default font type and size is left up to the user agent.
No standard correlation exists between the size used in
a <font> tag and the actual font size used by the user
agent. As such, the default size of the font (1-7) varies
between user agents.
|
C 8H8A P T E R
✦✦✦✦ In This Chapter Methods of Text Control Bold and Italic Text Monospace (Typewriter) Fonts Superscripts and Subscripts Abbreviations Marking Editorial Insertions and Deletions Grouping Inline Elements with the <span> Tag ✦✦✦✦ |
128 Part II ✦ HTML/XHTML Authoring Fundamentals
|
For example, if you wanted larger text in a red color, you could use a tag similar to
the following:
<font size=“+3” color=“red”>this is larger, red text</font>
Note that using “+3” for the size increases the text within the tag by a factor of 3 from
the base font size.
Emphasis and other text tags You can use a handful of tags to emphasize portions of text. Although these tags have not been deprecated in HTML 4.01, it is strongly recommended that you make use of CSS instead. Table 8-1 lists the emphasis tags and their use. A sample of their use is shown in Figure 8-1. Tag Use <cite> Citation <code> Code text <dfn> Definition term <em> Emphasized text <kbd> Keyboard text <samp> Sample text <strong> Strongly emphasized text <var> Variable(s) The creation and adoption of these tags seems somewhat haphazard. As such, the support for the tags is not standard across user agents—you may not be able to tell the difference between text coded with <cite> or <em>, for example. CSS text control CSS provides several different properties to control text. Table 8-2 lists some of the more popular properties. As you can see, CSS offers a bit more control over your text, allowing you to specify actual fonts and actual font sizes. However, the advantage to using CSS properties over hardcoded tags is not found in the list of available properties, but in the flexibility in formatting and effecting later changes. For example, suppose you were
Table 8-1
Emphasis Tags |
Chapter 8 ✦ Text 129
|
Figure 8-1: An example of text using emphasis tags.
Property
color font font-family font-size
Values
Color font-style font-variant font-weight font-size family-name font-size
Use
Change the color of text Shortcut property for setting font style, variant, weight, and size Set the font family (face) Set the font size
Table 8-2
CSS Text Properties
font-stretch
normal | wider | narrower |
ultra-condensed |
extra-condensed | condensed |
semi-condensed |
semi-expanded | expanded |
extra-expanded |
ultra-expanded
Expand or compress the letter
spacing
Continued
|
130 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Property
font-style font-variant font-weight text-decoration
Table 8-2 (continued)
Normal | italic | oblique
Normal | small-caps Normal | bold | bolder | lighter none | underline | overline | line-through | blink
Use
Set font to italic Set small-caps Set font to bold Set under/overlining
Values
text-transform none | capitalize | uppercase | Transform font capitalization
lowercase
creating documentation for a programming language and wanted to format all
reserved words a particular way—perhaps in a slightly larger, red, bold font. Using
tags, the code would resemble the following:
<p>The <font size=“+1” color=“red”><b>date</b></font>
function can be used to...
Later, you might decide that the red color is too much emphasis, and larger, bold text
is enough. You must then change every <font> tag used around reserved words.
Suppose, instead, that you used CSS, as shown in the following code: <head>
<style type=“text/css”>
.reservedword { font: 14pt bold; color: red }
</style>
</head>
<body>
<p>The <span class=“reservedword”>date</span> function can
be used to...
If you later decided to change the formatting of reserved words, you would only have
to make one change to the style definition at the top of the document. (If you used an
external style sheet, that one change could change an unlimited number of
documents that used the sheet.)
Bold and Italic Text Two surviving text emphasis tags are bold and italic. Their effect on text is, as expected, to make it bold or italic, as shown in the following code example and in Figure 8-2: <p>This is normal text.</p>
<p><b>This is bold text.</b></p>
<p><i>This is italic text.</i></p>
|
Chapter 8 ✦ Text 131
|
Note
Figure 8-2: Bold and italic tags at work.
Not every font has a bold and/or italic variant. When possible, the user agent will substitute a similar font when bold or italic is asked for but not available. However, not all user agents are font-savvy. In short, your mileage with these tags may vary depending on the user agent being used. For the same reasons mentioned elsewhere, it is advisable to use CSS instead of hardcoded bold and italic tags.
Monospace (Typewriter) Fonts
Another text tag that has survived deprecation is the teletype (<tt>), or monospaced, tag. This tag tells the user agent that certain text should be rendered in a monospaced font. Such uses include reserved words in documentation, code listings, and so on. The following code shows an example of the teletype tag in use: <p>Consider using the <tt>date</tt> function instead.</p>
This tag is named for the teletype terminals used with the first computers, which
were only capable of printing in a monspaced font.
|
132 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Tip
Again, the use of styles is preferred over individual inline tags. If you need text
rendered in a monospace font, consider directly specifying the font parameters
using styles instead of relying upon the <tt> tag.
Superscripts and Subscripts
There are two tags, <sup> and <sub>, for formatting text in superscript and subscript. The following code shows an example of each tag, the output of which is shown in Figure 8-3. <p>This is normal text.</p>
<p>This is the 16<sup>th</sup> day of the month.</p>
<p>Water tanks are clearly marked as H<sub>2</sub>O.</p>
Figure 8-3: Examples of superscript and subscript.
Abbreviations
You can use the abbreviation tag (<abbr>) to mark abbreviations and, optionally, give readers the expansion of the acronym used. For example, you could use this tag with acronyms such as HTML: <abbr title=“Hypertext Markup Language”>HTML</abbr>
|
Chapter 8 ✦ Text 133
|
Note that the expansion of the abbreviation is placed in the <abbr> tag’s title
attribute. Some user agents will display the value of the title attribute when the
mouse/pointer is over the abbreviation.
Marking Editorial Insertions and Deletions To further strengthen the bond between HTML documents and printed material, the insert and delete tags have been added to HTML. Both tags are used for redlining documents—that is, a visually marked-up document showing suggested changes. For example, the following paragraph has been marked up with text to be inserted (underlined) and deleted (strikethrough). The output of this code is shown in Figure 8-4. <p>Peter <del>are</del><ins>is</ins> correct, the proposal
from Acme is lacking a few <del>minor </del>details.</p>
Figure 8-4: The <ins> and <del> tags can provide for suitable redlined
documents.
Note that the underline tag (<u>) has been deprecated in favor of the <ins> tag.
|
134 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Grouping Inline Elements with
the <span> Tag
When using CSS for text formatting, you need a method to code text with the appropriate styles. If you are coding block elements, you can use the <div> tag to delimit the block, but with smaller chunks (inline elements) you should use <span>. The <span> tag is used like any other inline tag (<b>, <i>, <tt>, and so on), surrounding the text/elements that it should affect. You use the style or class attribute to define what style should be applied. For example, both of the following paragraph samples would render the word red in red text: <head>
<style type=“text/css”>
.redtext { color: red; }
</style>
</head>
<body>
<!-- Paragraph 1, using direct style coding -->
<p>We should paint the document <span style=“color: red”>
red</span>.</p>
<!-- Paragraph 2, using a style class -->
<p>We should paint the document <span class=“redtext”>
red</span>.</p>
</body>
Of the two methods, the use of the class attribute is preferred over using the style
attribute because class avoids directly (and individually) coding the text. Instead,
it references a separate style definition that can be repurposed with other text.
Summary This chapter covered the formatting of inline elements. You learned two distinct methods (direct tags and styles) and the various tags to supplement textual formatting. Keep in mind that you should use <div> or other block tags to format larger sections of a document. ✦✦✦ |
Creating Links In HTML
Links
Links are what make the World Wide Web web-like. One document on the Web can link to several other documents, and those in turn to other documents, and so forth. The resulting structure, if diagramed, resembles a web. The comparison has spawned many “web” terms commonly used on the Internet—electronic robots that scour the Web are known as “spiders,” and so on. Besides linking to other documents, you can link to just about any content that can be delivered over the Internet—media files, e-mail addresses, FTP sites, and so on. This chapter covers the ins and outs of linking to references inside and outside the current document and how to provide more information about the relationship of your documents to others on the Web. What’s in a Link? Web links have two basic components, the link and the target.
<a href=“url_of_target”>descriptor_text</a>
|
C 7 7H A P T E R
✦✦✦✦ In This Chapter What’s in a Link? Linking to a Web Page Absolute versus Relative Links Link Targets and Titles Keyboard Shortcuts and Tab Order Creating an Anchor Choosing Link Colors The <link> Tag ✦✦✦✦ |
114 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Review
xyz Software Developed by xyz Inc
xyz Inc
Home Page
Note
Figure 7-1: The relationship of documents on the
Web via links—the user clicks the link in the review
document to reach the xyz Inc. home page.
The target reference is specified via the href attribute, and the descriptor appears between the start and end anchor tags. For example, if the manufacturer is Acme Computers and its Web site is acme.example.com, the anchor tag would resemble the following: <a href=“http://www.example.com”>Acme Computer’s Web Site</a>
If you don’t give the name of a document in the link, the Web server (in this case,
www.example.com) will send the defined top-level document (known as an index
document)—typically, this document is named index.html or home.html. If such
a document doesn’t exist or one has not been defined for the server, an error will be
returned to the client browser.
The text “Acme Computer’s Web Site” would be highlighted in the document to show it is a link. The default highlight for a link is a different color font and underlined, though you will see how to change the highlight later in this chapter. According to the “strict” HTML standard, anchor links need to be placed within block elements (headings, paragraphs, and so on). As mentioned in the introduction to this chapter, you can link to other things besides HTTP documents. All you need is the URL of the item you wish to link to, and the protocol necessary to reach the item. For example, if you wanted to link to a document on an FTP site, you could use an anchor tag similar to the following: <a href=“ftp://ftp.example.com/pub/example.zip”>Zipped copy of the files</a>
Note that the protocol is specified (ftp: instead of http:), and the server name is
specified (ftp.example.com), as is the path and filename (/pub and example .zip). A similar method can be used to link to an e-mail address (href=“mailto:someone@example.com”). Clicking such a link will generally spawn the user’s e-mail client ready to send an e-mail to the address specified. |
Chapter 7 ✦ Links 115
|
Note The rest of this chapter concentrates on linking to other HTML documents on the
Web. However, all the concepts addressed apply when linking to other content
types.
Linking to a Web Page
The most popular link style on the Web is a link to another Web page or document.
Such a link, when activated, causes the target page to load in the client browser.
Control is then transferred to the target page—its scripts run, and so on.
To link to another page on the Internet, you simply specify the target’s URL in the anchor tag. Suppose you want to link to the products page of the Acme Web site and the page is named products.html and resides in the products directory on the Acme Web server. The href parameter of the link would be as follows: http://www.example.com/products/products.html
Note that the URL (http://acme.example.com) contains the protocol, the server
name, the directory name, and the filename. Figure 7-2 shows a breakdown of the
various pieces of the URL.
http://www.example.com/products/products.html
protocol
directory
✦
✦
✦
✦
The protocol is first, and ends with a colon (http:).
The server name is next, prefaced with a double slash (//www.example.com). The directory (or directories) is next, separated with slashes (/products/). The filename of the page is last, separated from the directory by a slash (products.html). The server name is actually two pieces, the server’s name and the domain on which it resides. In the www.example.com, www is the server name and example.com is the domain. There is a common misconception that all Web server names need to begin with www. Although www is a standard name for a Web server, the name can be almost anything. For example, the U.S.-based Web server for the Internet Movie Database (imdb.com) is us.imdb.com.
server
file/page
Figure 7-2: The various pieces of a URL.
In the case of this URL, the various pieces are separated by various key characters:
Note
|
116 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Absolute versus Relative Links
There are two types of URL styles, and therefore two link types, that you need to understand: absolute and relative. You have seen absolute links, where the URL used in the link provides the full path, including the protocol and full server address. These links are called absolute links because the URL itself is absolute—that is, it does not change no matter where the document in which it appears is kept. The other type of link, a relative link, does not provide all of the details to the referenced page; hence, its address is treated as relative to the document where the link appears. Relative links are only useful for linking to other pages on the same Web site, because any reference off of the same site requires the remote server’s name. It’s easier to understand the difference between the two types of links with an example. Suppose you are the Webmaster of example.com. You have several pages on the site, including the home page, a main products page, and hardware and software products pages. The home page is in the root directory of the server, while the product pages (all three) are in a products directory. The relative links back and forth between the pages are shown in Figures 7-3 and 7-4.
Root Directory (/)
/products/products.html
Home
Products
Directory
(/products)
./hardware.html ./software.html
Hardware
Products
Software
Figure 7-3: Relative links to subpages.
Note that you can use directory shortcuts to specify where the pages are:
|
Chapter 7 ✦ Links 117
|
Home
Root Directory (/)
../home.html
Products
Directory
(/products)
./products.html ./products.html
Hardware
Products
Figure 7-4: Relative links to parent pages.
Software
Relative links are easier to maintain on sections of Web sites where the pages in that
section never change relationships to one another. For example, in the case of the
site shown in Figures 7-3 and 7-4, if the products pages move as a whole unit to
another place on the site, the relative links between the product pages won’t change.
If the links were coded as absolute (for example, http://www.example.com/
products/hardware.html), they would have to change.
Link Targets
Note
Normally, links open the page they refer to in the active browser window, replacing
the page currently displayed. However, you can control where the page opens using
the target attribute in the link tag.
The target attribute has been deprecated in strict HTML. It appears here be- cause most browsers still support the attribute and it can be useful. However, keep in mind that your documents will not validate against strict HTML if you use the target attribute. The target attribute supports the values shown in Table 7-1. Value Description _blank Opens the linked document in a new browser window _self Opens the linked document in the same frame as the link
Table 7-1
Target Attribute Values
Continued
|
118 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Table 7-1 (continued)
Value Description
_parent Opens the linked document in the parent frameset _top Opens the linked document in the main browser window, replacing any and all frames present name Opens the linked document in the window with the specified name For example, to open a linked document in a new window you would use a tag similar to the following: <a href=“http://www.example.com” target=“_blank”>
New Window</a>
Caution
The debate about whether you should ever open a new window is fierce. Most
users are accustomed to all new windows being of the pop-up ad variety—and
very unwelcome. However, from a user interface standpoint, new windows can
be used very effectively if they are used like dialog boxes or new windows that
an operating system spawns. In any case, you should make a habit of informing
users when you are going to open a new window so you don’t surprise them.
The last value listed for target, name, can also aid in the user interface experience, if
used correctly. Certain methods of opening windows (such as the JavaScript
window.open method) allow you to give a browser window a unique name. You can
then use that name to push a linked document into that window. For example, the
following code displays two links; the first opens a new, empty browser window
named NEWS, and the second pushes the content at www.yahoo.com into the
window:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<script language=“JavaScript”>
function NewsWindow(){
fin=window.open(“”,“NEWS”,“width=400,height=400”);
}
</script>
</head>
<body>
<p><a href=“JavaScript:NewsWindow()”>Open Window</a></p>
<p><a href=“http://www.yahoo.com” target=“NEWS”>Fill Window</a></p>
</body>
</html>
Cross-
Reference
For more information on JavaScript and the window.open method, refer to
Chapter 25.
|
Chapter 7 ✦ Links 119
|
Link Titles
You can also title a link, using the title attribute in the anchor tag. This causes most current browsers to display the text of the title as a ToolTip when the mouse hovers over them. For example, the following link will cause Internet Explorer 6 to display “Example.com’s Web Site,” as shown in Figure 7-5. More information can be found <a
href=“http://www.example.com” title=“ Example.com’s Web
Site”>here</a>.
Figure 7-5: The title attribute causes a ToolTip
display when the mouse hovers over the link.
You can use this feature to give the user more information on the link, before they click it. Keyboard Shortcuts and Tab Order In the modern world of computers it is easy to make assumptions about users, their hardware, and capabilities. Several years ago, no one would have dreamt of delivering rich, multimedia content over the Web. Today, however, it is easy to assume that everyone is using the latest browser, on a high-end computer, across a broadband connection. However, that isn’t always the case. In fact, some users who visit your site may not even have a mouse to aid in browsing. The reason could be a physical handicap, a text-only browser, or just a fondness for using the keyboard. It is important to |
120 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Tip
accommodate these users by adding additional methods to access links on your
page.
Keyboard shortcuts Each link can be assigned a shortcut key for easy keyboard-only access using the accesskey attribute with the anchor tab. The accesskey attribute takes one letter as its value, the letter that can be used to access the link. For example, the following link defines “C” as the access key: <a href=“http://www.example.com” accesskey=“C”>Table of
<b>C</b>ontents</a>
Note that different browsers and different operating systems handle access keys
differently. Some browser and operating system combinations require special keys
to be pressed with the defined access key. For example, Windows users on Internet
Explorer need to hold the Alt key while they press the access key. Note, also, that
different browsers handle the actual access of the link differently—some browsers
will activate the link as soon as the access key is pressed, while others only select
the link, requiring another key to be pressed to actually activate the link.
Keyboard shortcuts won’t help your users if you don’t give them a clue as to what the shortcut is. In the example earlier in this section, the defined shortcut key (“C”) was used in the link text and highlighted using the bold font attribute.
Tab order
It will also help your users if you define a tab order for the links in your document. As with most graphical operating systems, the tab key can be used to move through elements of the interface, including links. Typically, the default tab order is the same as the order that the links appear in the document. However, upon occasion, you might wish to change the order using the tabindex attribute. The tabindex attribute takes an integer as its value; that integer is used to define the tab sequence in the document. For example, the following document switches the tab order of the second and third links: <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>Tab Ordered Document</title>
</head>
<body>
<p>This is the <a href=“http://www.example.com”
tabindex=“1”>first link</a>.</p>
<p>This is the <a href=“http://www.example.com”
tabindex=“3”>second link</a>.</p>
|
Chapter 7 ✦ Links 121
|
Note
<p>This is the <a href=“http://www.example.com”
tabindex=“2”>third link</a>.</p>
</body>
</html>
As with most interface elements in HTML, the browser defines how tabindex
is implemented and how tabbed elements are accessed.
Creating an Anchor
Anchor tags have another use; they can be used as a marker in the current document to provide a bookmark that can be directly linked to. For example, a large document might have several sections. You can place links at the top of the document (or in a special navigation frame) to each section, allowing the user to easily access each section. To create an anchor in a document, you use the anchor tag with the name attribute. For example, the following code creates a chapter01 anchor at the “Chapter 1” heading: <h1><a name=“chapter1”>Chapter 1</a></h1>
To link to the anchor you use a standard link, but add the anchor name to the end of
the URL in the link. To identify the name as an anchor, you separate it from the rest
of the URL with a pound sign (#). For example, suppose the Chapter 1 anchor
appears in the document book.html. To link to the Chapter 1 anchor, you could use
the following code:
<a href=“http://www.example.com/book.html#chapter1”>Go to Chapter 1</a>
Note Because the URL in the link tag can contain the server and document names as
well as the anchor name, you can link to anchors in the same document or any
accessible document. If you are linking to an anchor in the same document,
you can use a shortcut form of the URL, using only the pound sign and the
anchor name as the URL.
In addition to using the anchor tag for bookmarks, you can link to a block element’s id attribute. For example, if Chapter 1 appears inside an <h1> tag, you can set the <h1> tag’s id attribute to Chapter1 and omit the anchor link altogether, as shown in the following code example: <h1 id=“chapter1”>Chapter 1</h1>
Choosing Link Colors
It is important that links stand out from the normal content in your documents. They need to be recognizable by users. Each link has four different status modes: |
122 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Note
✦
✦
✦
✦
Link—Blue, underlined text
Active—Red, underlined text Visited—Purple, underlined text Hover—No change in the appearance of the link (remains blue, red, or purple) As with other presentation attributes in HTML, the browser plays a significant role in setting link colors and text decorations. Most browsers follow the color scheme outlined in this section, but there are browsers that don’t conform to this scheme.
To change the text color and other attributes of links, you can modify the properties
of each type of anchor tag. For example, the following style, when used in an HTML
document, sets the default visited link text to bold and yellow:
Tip
a:visited { color: yellow; font-weight: bold; }
Setting the properties of the anchor tag without specifying a mode changes all
of the link modes to the characteristics of the style. For example, this style sets
all types of links (link, active, visited) to red:
a { color: red; } So why would you want to change the color of links in your document? One reason would be that the normal text of your document is the same color as the default link. For example, if your text is blue, you probably want to change the default color of the links in your document to better enable users to recognize them. It is a good idea to define all of the link attributes instead of haphazardly defining only one or two of the link status colors. The following styles define each type of link, ensuring they appear how you want in the document: a:link { color: #003366;
font-family:verdana, palatino, arial, sans-serif;
font-size:10pt; text-decoration: underline; }
a:visited {color: #D53D45;
font-family:verdana, palatino, arial, sans-serif;
font-size:10pt; text-decoration: underline; }
|
Chapter 7 ✦ Links 123
|
a:active {color: #D53D00;
font-family:verdana, palatino, arial, sans-serif;
font-size:10pt; font-weight: bold;
text-decoration: underline; }
a:hover {color: #D53D45;
font-family:verdana, palatino, arial, sans-serif;
font-size:10pt; text-decoration: none; }
Note the redundancy in the styles—there are only subtle changes in each style. You
should strive to eliminate such redundancy whenever possible, relying instead upon
the cascade effect of styles. You could effectively shorten each style by defining the
anchor tag’s attributes by itself, and defining only the attributes that are different for
each variant:
a { color: #003366;
font-family:verdana, palatino, arial, sans-serif;
font-size:10pt; text-decoration: underline; }
a:visited {color: #D53D45; }
a:active {color: #D53D00; font-weight: bold; }
a:hover {color: #D53D45; text-decoration: none; }
Link Target Details
There are a host of other attributes that you can add to your anchor tags to describe the form of the target being linked to, the relationship between the current document and the target, and more. Table 7-2 lists these descriptive attributes and their possible values. Attribute Meaning Value(s) Hreflang The base language of the target language_code for example, “en-US”
Table 7-2
Link Target Details
Charset The character encoding of the target char_encoding
for example, “ISO 8859-1”
Rel The relationship between the current
document and the target
alternate
designates
stylesheet
start
next prev contents
Continued
|
124 Part II ✦ HTML/XHTML Authoring Fundamentals
|
Attribute Meaning
Table 7-2 (continued)
Value(s)
Rev The relationship between the target
and the current document
alternate
designates
stylesheet
start
next prev contents index glossary copyright chapter section subsection appendix help bookmark Any valid MIME type
Type The MIME type of the target
index
glossary
copyright
chapter
section
subsection
appendix
help
bookmark
An example of how the relationship attributes (rel, rev) can be used is shown in
the following code snippet:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>Chapter 10</title>
</head>
<body>
<p><a href=“contents.html” rel=“chapter” rev=“contents”>Table of
Contents</a></p>
<p><a href=“chapter9.html” rel=“next” rev=“prev”>Chapter 9</a></p>
<p><a href=“chapter11.html” rel=“prev” rev=“next”>Chapter 11</a></p>
...
The anchor tags define the relationships between the chapters (next, previous) and
the table of contents (chapter, contents).
|
Chapter 7 ✦ Links 125
|
The Link Tag
You can use the link tag to provide additional information on a document’s relationship to other documents, independently of whether the current document actually links to other documents or not. The link tag supports the same attributes as the anchor tag, but with a slightly different syntax: ✦ The link tag does not encapsulate any text. ✦ The link tag does not have an ending tag. For example, the following code could be used in chapter10.html to define that document’s relationship to chapter9.html and chapter11.html: <link href=“chapter9.html” rel=“next” rev=“prev” />
<link href=“chapter11.html” rel=“prev” rev=“next” />
The link tag does not result in any visible text being rendered, but can be used by
user agents to provide additional navigation or other user-interface tools.
Another important use of the link tag is to provide alternate content for search engines. For example, the following link references a French version of the current document (chapter10.html): <LINK lang=“fr” rel=“alternate” hreflang=“fr”
href=“http://www.example.com/chapter10-fr.html” />
Other relationship attribute values (start, contents, and so on) can likewise be
used to provide relevant information on document relationships to search engines.
Summary This chapter covered links—what they are and how to use them to reference other content on the Web. You learned how to construct a link and what attributes are available to the anchor and link tags. You also learned how to define relationships between your document and other documents, and why this is important. From here, you should progress through the next few chapters, familiarizing yourself with the other various pieces of an HTML document. ✦✦✦ |