Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Computers & Technology

Building a Website
published by Barnes & Noble

Be master of your domain.


Whether you want to promote your business, create a forum for keeping in touch
with family and friends, or discuss your favorite band or hobby, you can do so by
creating and publishing your own website. Hone your skills by learning to:

• Identify the main components of a website

• Read the language used to create online content

• Design and format a website that's appealing and easy to navigate

• Hypertext: This is electronic text that contains links. Choosing a Domain Name
Website Basics • HTML: An acronym for hypertext markup language, Before allowing you to register a domain name, registrars
The world wide web (www), often referred to simply as HTML is the computer code used to create web pages. will check to make sure it‘s not already registered. To find
the web, is an electronic network of websites, or sites for • CSS: An acronym for cascading style sheets, CSS out whether your domain is available, visit www.whois.net.
short. A website is a collection of web pages (digital docu- documents control the appearance and positioning of When selecting a name:
ments) stored on a computer. Other people can view web web page content.
pages from any computer that’s connected to the internet, • FTP: An acronym for file transfer protocol, FTP is soft- • Choose as brief a name as possible.
a vast worldwide network of millions of computers. The ware used to move files between computers. Website • Avoid using hyphens, which users can forget easily.
world wide web is just one of many internet services. builders use FTP to upload HTML files to servers. • If the names you prefer are all taken, try pluralizing the
Anyone can build and publish a website at a low cost and name, adding “the” to the beginning of the name, or
without much technical know-how. Here’s how to get your How Web Pages Are Served coining an original term.
website started: When you open up your browser and view a web page, an
exchange between your computer (the client) and a remote Domain Extensions
• Register a domain name for your site. computer (the server) has already taken place. Here’s a Domain extensions, or top-level domains (TLDs), are the
• Purchase a web hosting program on which to store quick breakdown of what happens: suffixes attached to domain names. You’re probably most
your files. familiar with .com and .net, the most popular TLDs for per-
• Plan and organize your website. 1. You type a URL into your browser’s blank address bar. sonal sites, and .org, a TLD used mainly by organizations.
• Learn to use HTML and CSS to create web pages. 2. Computers called name servers then point your But many more exist, such as .info and .biz. View a complete
• Add images to your web pages. browser to other computers whose IP addresses are selection of TLDs at ICANN’s accredited registrars page.
• Publish and promote your site. associated with the domain name in the URL.
3. Your browser loads the page you requested and its
How the Web Works related components from the server where they reside. How to Select a Web Host
To understand how the web works, familiarize yourself with 4. The browser formats the page for viewing based on Once you’ve registered your domain name, it’s time to
some basic terminology: the instructions in the CSS and HTML documents choose a web host. A web host is a business that rents out
associated with the web page you requested. the server space on which you store all of your website’s
• Browser: This software program is used to view web files. Look for a web host that’s backed by a reliable cor-
pages. Popular browsers include Microsoft Internet poration with a good reputation for customer service. For
Explorer, Mozilla Firefox, and Safari. How to Register a Domain Name instance, it’s probably safer to use Yahoo! web hosting
• Domain name: The main name of a website. It usually The first step in building your own website is to register (webhosting.yahoo.com) than a small host you don’t know.
begins with www and ends in .com, .org, .net, or your domain name through a domain name registrar. Once
another suffix. To access a site, users type its domain you’ve registered and paid for a domain name, you own Hosting Features
name into a browser. For instance, in www.quamut. it, which means you have the exclusive right to use that Before signing a contract, make sure you understand the
com, “quamut.com” is the domain name. domain name for a specified period of time and renew it hosting features available to you:
• URL: An acronym for uniform resource locator, a URL once that term expires. Domain name registration is usually
is the unique address of each page on the web. It can effective for a year at a time. • Shared vs. dedicated hosting: With a shared hosting
refer to entire sites, such as www.quamut.com, or plan, your site shares space with other sites on a
specific pages, such as www.quamut.com/about.html. Selecting a Registrar server, whereas with a dedicated server plan, a server
URLs usually include the prefix http://. There are many registrars to choose from. The factors to is reserved exclusively for your website. Shared hosting
• IP address: Each computer on the internet is assigned consider when choosing one are accreditation and cost: plans are less costly but may make your web pages
a specific numerical address, called an IP address. Each load more slowly. Unless your site attracts thousands
domain name is associated with at least one IP address. • Accreditation: Only use a registrar listed on the of users per day, though, shared hosting should suffice.
• Client/server: Clients are computers used to view web Internet Corporation for Assigned Names and • Disk space: This is the amount of space your site can
pages. Servers are computers that serve, or distribute, Numbers (ICANN) website located at www.icann.org/ take up on your rented server. Exactly how much disk
web pages. registrars/accredited-list.html. space you need depends on the number of pages you
• Link: This is an electronic reference that connects one • Cost: Though some registrars charge up to $40, expect your site to contain and what types of files you
web page, or site, to another. Web users move from avoid paying more than $10 per year to register your plan to offer users. For instance, images and audio files
one site to another by clicking on links. domain name. Among the most reliable and cheapest take up much more space than text files. Opt for a host
accredited registrars is Go Daddy (www.godaddy.com). that offers at least 3 gigabytes (GB) of storage space.
www.quamut.com Building a Website

• Data transfer: Also known as bandwidth, this is the • User acquisition: Explain how you intend to attract 2. Create a folder called “home page” in which you’ll
amount of data you can transfer from your site to other your audience—through advertising, word of mouth, place files that you’ll use only on the site’s home page,
computers in a given month. Be sure to choose a plan special promotions, and so on. or front page.
with data transfer limits of at least 100 GB per month. • Content: Detail what types of text and images you 3. Create separate folders for each of the site’s main
• POP/SMTP access: This type of email protocol allows want your site to contain. components, such as “contact” and “FAQ.”
you to use email addresses with your site’s domain • Look and feel: Describe the site’s aesthetics, such as 4. Create subfolders for any of the site’s main
(you@yoursite.com). Most hosts let you use a web- the color palette you’d like to use and the overall tone components that require them. In this case, the “book
based version of your site’s email for free. If you’d like or attitude you intend to convey. reviews” folder requires three subfolders: “international
to download and manage your email on your local • Layout: Consider how you’ll organize each page to bestsellers,” “new releases,” and “forthcoming titles.”
desktop PC, though, be sure your web host offers allow users to navigate easily among pages on the site. 5. Store the files you plan to use for each section of the
POP/SMTP access. • Schedule: Determine deadlines for creating drafts of site within the appropriate folders.
the site and launching the final product.
Other Hosting Features to Consider Each folder you create on your hard drive should eventually
• Customer service: Some hosting companies offer Draw a Site Map have a directory on your site with the same name, preceded
customer service via email only. Sign up for hosting Once you have your site plan in place, you’re ready to by a forward slash (/). For example, the files you store in your
only with a company that offers telephone support. create a site map, or a visual depiction of your site’s basic “contact” folder will eventually reside in an online directory
• Control panel: This is an interface that allows you to architecture. Use the site map as a blueprint when creating located at http://www.yoursite.com/contact.
manage email addresses, configure your account, and the pages that make up your website. Your site map should But note one exception: the files in your “home page”
monitor site statistics, such as number of visitors. include each of the site’s main pages and show how they folder won’t go in a directory called “home page.” Instead,
• E-commerce: Some plans offer built-in or easy-to- link together to form the overall hierarchy of the website. those files will likely reside in the root directory, your site’s
configure storefront applications. If you’re planning to You can draw a site map on paper or with image editing topmost directory in which all of your other folders will be
sell on the web, consider buying a plan with this option. software, such as Adobe Illustrator or Photoshop. A site stored. You don’t have to match your folder names exactly
map for a book-review site might look like this: to your site’s directory names, but doing so may help you
Configuring Your Domain Name keep your files organized.
Once you’ve registered a domain and bought a web hosting
plan, you’ll need to configure your domain. This way, other home page Create a Separate Folder for Images
computers know where to look for your files when someone It’s a good idea to create one folder in which you store all
enters one of your site’s URLs into a browser. To make sure of your image files and keep only text documents in your
your domain is correctly configured, you must change your main folders. That way, specific image files are easy to find
domain’s DNS (domain name server) settings. Here’s how: about us book FAQ contact search because they all reside in one place. People typically name
reviews information
their image folder “images” or “img.”
1. When you sign up for hosting, your web host provides
you with the DNS info you need. The DNS info will look international Assemble Your Content
bestsellers
something like this: ns1.yoursite.com. Before you can begin to create your web pages, you need to
2. Enter the DNS info into the DNS settings configuration gather all the content you expect your site to contain when
page on your registrar’s site. This option is usually new you launch, or first publish, the site. The core content of
releases
located under My Account or Settings. most sites is text and images.
3. After about 24 hours, your domain becomes associated
with the servers on which your files reside, and your forthcoming • Text: This includes introductory material, biographical
titles
site can be found by any browser into which someone information about you and/or your organization, main
types your URL. Organize Files into Folders and Directories content, and any other information that will appear on
Websites are essentially collections of files located on a your site. You can create this content with standard word
server and organized in a particular structure, called a di- processing software and import it into your web page
How to Plan Your Website rectory structure. Note that what you probably call folders documents later.
Before you begin building the web pages that will make up on your computer are called directories on the web. Folders • Images: These are the photos, illustrations, logos, and
your site, do some preliminary planning and organization: and directories serve the same purpose: to organize related other visual material you plan to include on your site
files into groups and subgroups. (see How to Add Images to Your Web Pages).
• Draft a site plan. When you make your website, you’ll create the files on
• Draw a site map. your computer and then upload them to the proper direc- As you gather and create your content, make sure to store
• Organize files into folders and directories. tories on your web host’s server (see How to Publish Your it within the proper folders. For example, once you’ve as-
• Assemble your content. Website). To streamline the process of uploading your site’s sembled the text for your contact information page, store
files from your hard drive to your server, create a group of the files that contain that text in your “contact” folder.
Draft a Site Plan folders on your hard drive that mirrors the directories you As you assemble image files, store all of the files in your
Your site plan outlines the purpose and goals of your web- plan to use on your site. These folders should derive from image folder.
site. It should address the following issues: the components of your site map. For example, to build
the book-review site in the site map example above, you’d
• Purpose: Clarify your reasons for building the site and follow these steps: How to Design Your Website
list the site’s goals, ranked by importance. The primary goal of website design is to combine
• Audience: Define the types of users you expect your 1. Make a main folder for your site on your hard drive and usability, or ease of use, with a pleasant and appropriate
site to attract. name it appropriately—in this case, “book-review site.” look and feel, or overall appearance.

The information contained in this and every Quamut guide is intended only for the general interest of
its readers and should not be used as a basis for making medical, investment, legal or other important
decisions. Though Quamut makes efforts to create accurate guides, editorial and research mistakes can
occur. Quamut cannot, therefore, guarantee the accuracy of its guides. We disclaim all warranties, including
www.quamut.com
warranties of merchantability or fitness for a particular purpose, and must advise you to use our guides at Copyright © 2007 Quamut
your own risk. Quamut and its employees are not liable for loss of any nature resulting from the use of or
All rights reserved.
reliance upon our charts and the information found therein.
Quamut is a registered trademark of
Barnes & Noble, Inc.
10 9 8 7 6 5 4 3 2 1
Printed in the United States

Photo credit: Page 1: Good Shoot/Corbis. Illustrations copyright © 2007 by Quamut.


Writer: Frances Duncan
www.quamut.com Building a Website

Usability • Use background colors wisely: Whatever background • Open tags: An open tag, such as <b> , follows the
A site with usability lets visitors get the information they color you choose, be sure to select a text color that’s basic HTML format.
need quickly and easily. Your website’s usability is deter- readable against that color. Black text on a white • Close tags: A close tag adds a forward slash (/) to an
mined by the layout that you use throughout the site. background is the most legible option. open tag. For instance, </b> is the close tag for <b>.
• Style your text and links: Unless you specify text Unless it’s otherwise specified, assume that every open
Website Layout and link colors in your style sheet (see Cascading Style tag has a corresponding close tag.
Layout is the arrangement of the core elements that appear Sheets), your browser will default to a combination of • Self-closing tags: Some HTML tags, such as <br> (for
on each page of a website. These elements include: black, blue, and purple text. line breaks) and <img> (for images), include a forward
slash at the end of the open tag to indicate that the tag
• Header: An area at the top of the page that typically How Color Works on the Web should be opened and closed at once. You don’t need
contains the page title and graphic. It may also contain You have a choice of 216 web-safe colors to use on your web to use a close tag with these tags.
navigation elements (see below). pages. These colors are “safe” because they appear consis-
• Navigation: This refers to the tools that visitors use tently on all browsers and platforms (Mac, PC, and so on). To bold a selection of text and create a line break, you
to move among the pages of the site. Navigation can Each web-safe color has a unique hex code, a six-digit com- would write:
appear in a horizontal header at the top of the page, bination of letters and numbers preceded by a pound sign
drop-down menus (called pull-downs), or vertical (for example: #336699). To see a complete list of web-safe <b>This text will be bold.</b> <br />
sidebars (columns along either side of the main colors with hex codes, search online for “web-safe colors.”
content area that often contain advertising as well). Nesting Tags
• Core content: This is the page’s main text or images, Fonts HTML tags are often nested, meaning that tags that appear
which the user has come to the site to read or see. The fonts, or type styles, you can use on your site are lim- first are closed last, and they can contain other open and
• Footer: The footer is an area at the bottom of the page ited by the number of fonts installed on a typical computer. close tags within their own tags. For instance, you can nest
that typically contains links to legal information as well To keep your website clean and readable by all users, use the bold (<b>) and italic (<i>) tags so that:
as navigation to the site’s main pages. just one font. The most common fonts are: Verdana, Arial,
Times New Roman, and Courier. <b>This text will be just bold. <i>This text will be
italic and bold.</i> This text will be just bold.</b>
The text on your site can also be customized according to
header font size and style, such as bold or italic (for details on cus- HTML Tag Attributes
tomizing text, see Cascading Style Sheets). Some HTML tags can also contain attributes, which modify
a tag or provide it with extra information. Attributes appear
Images in the tag a space apart from the tag name and are followed
Images on the web usually appear in one of three ways: by an equal sign (=) and a value that’s written in quotes. For
example, take the following tag:
• Background images: These repeat, or tile, in the
navigation
(sidebar) core content background of a web page. In general, you should avoid <img src = "logo.jpg">
using these, as they tend to make text illegible.
• Inline images: These usually appear next to a portion The name of this tag is img, the attribute is src, and the
of text that wraps around the image and are ideal value of the attribute is logo.jpg. The value logo.jpg tells the
for smaller images that complement the text, as on browser to insert an image. (For more on inserting images,
news sites. see How to Add Images to Your Web Pages.)
• Block-level images: These appear on their own line
footer
above or below text and are best for use with large HTML Tagging Syntax
photos or illustrations. When writing HTML tags, it’s important to follow four funda-
How to Design Your Layout mental rules of HTML syntax:
Follow the three C’s to give your site a user-friendly layout. How you use images should depend on the look and feel you
prefer for your site. Some text-heavy sites, such as blogs • Write all tags in lowercase.
• Clean: Avoid clutter by including only crucial page and news sites, use images merely as accents to break up • Surround all attribute values with quotes.
elements and arranging them simply and neatly. text. Others, such as online photo galleries, make images • Close all open tags.
• Clear: Allow ample space between page elements to the main component of the site’s look and feel (see Adding • Open and close nested tags in the proper sequence.
make your content legible and inviting to the user. Images to Your Web Pages).
• Consistent: Maintain the same basic layout and How to Structure HTML Documents
navigational elements throughout the site. Every web page uses four required HTML tags. These tags
How to Build Web Pages with HTML organize the page and define its separate parts.
Look and Feel HTML stands for hypertext markup language: it uses
The look and feel of your site should appeal to the type special tags to “mark up” text and images. These tags tell • The <html> </html> tag: These tags surround all the
of users you expect to attract. It should also complement browsers how to organize and display the text and images text and all the other tags in the document and tell the
your site’s core content. To ensure that your site’s look and as a web page, though the tags themselves aren’t displayed browser that the document is written in HTML.
feel meets both of those goals, choose appropriate colors, to the viewer. HTML is also used to encode web pages with • The <head> </head> tag: Defines the page’s heading.
fonts, and images. hypertext links that connect web pages both within a site The heading includes information about the page, such
and between different sites. as the required <title> </title> tag and meta data,
Colors which search engines read to determine what type of
Your site should incorporate a color palette, or a set of col- HTML Tags content your site contains.
ors that complement one another. To get ideas for palettes All HTML tags share the following components: • The <title> </title> tag: Indicates the page’s title (“A
that might suit your site, search online for a color palette simple HTML document”). The web page title appears
generator, an online application that creates sample pal- • A less-than sign (<) on the browser, often near the middle or the top left.
ettes. The guidelines below will also help you use color to • A name written as a word or letter(s) • The <body> </body> tag: Defines the body of the
enhance your site’s look and feel. • A greater-than sign (>) web page, which contains the text and/or images that
make up the meat of the page and appears in the main
• Consider your audience: Your color palette should An example of an HTML tag is <b>, which bolds text. browser window.
vary depending on the demographics of your expected
audience. For instance, a fan site for a folk musician Open Tags, Close Tags, and Self-Closing Tags
would likely feature soft, welcoming colors, whereas a Nearly all HTML tags work as enclosures: each tag is actu-
site geared toward hard rock fans might include a lot of ally made up of an open tag and a close tag that surround,
black and other dark hues. or enclose, text. The open tag identifies where in the text a
particular formatting instruction begins, whereas the close
tag marks where that instruction ends.
www.quamut.com Building a Website

The Simplest Possible Web Page • Each table must contain at least one row. The value of href (in quotes after the equal sign) tells the
The simplest web page that browsers can read uses just the • Each row must contain at least one cell. browser which URL it should link to (in this case, http://
four required tags, as in the following example: • Tables can have visible borders, which show the www.quamut.com). The text between the opening and
boundaries of rows and cells, or invisible borders. closing of the anchor tag (in this case, the word Quamut) will
<html> appear as an underlined link in your browser.
<head> A typical table with visible borders might look like this:
<title> The HTML Image Tag
A simple HTML document To include images on your web pages, use HTML’s image
</title> tag, which looks like this:
</head>
<body> <img src = "../img/flowers.jpg" alt="flowers" />
This text will appear in the main browser window.
</body> The HTML code to create tables includes these tags: The image you reference in your image tag will appear in
</html> your browser wherever you place it within your HTML code.
Code Function For instance, images can appear within text paragraphs,
How to Create HTML Documents between paragraphs, in table cells, and so on. The parts of
<table> Creates a table.
You can create HTML documents in any text editor, including the image tag, as in the example tag above, are:
standard word processing software. It’s best, though, to use <tr> Creates a horizontal table row within the
software designed especially for HTML authoring. The two table. • img: This is the name of the tag itself.
main types of authoring software are WYSIWYG editors • src: This attribute stands for “source,” or the location
<td> Creates a cell within the table row.
and text editors. on the server of the actual image file.
• /img/flowers.jpg: This line instructs the browser
• WYSIWYG editors: WYSIWYG stands for “what you see The most common attributes used to control the size, to look in the img directory to find an image called
is what you get.” These programs, such as Microsoft orientation, and appearance of tables, rows, and cells are: flowers.jpg. The two dots mean that the directory “img”
FrontPage and Adobe Dreamweaver, don’t so much is located up one level from the default directory, or
help you write HTML as write it for you. They let you Attribute Function the directory in which the HTML file that calls for this
arrange the elements of your web pages visually, then image resides.
they generate the HTML code for you. <width> Sets width tables or table cells. • alt: This represents a text description of the image that
Example: <td width="200">
• Text editors: These programs make creating your own will appear if the image itself fails to load.
HTML code by hand easier with features such as auto- <align> Determines whether either table
correct and different colors for each type of tag. Text or table cell content aligns to left, A Sample Web Page Created with HTML
editors also make it easy to preview your results in a center, or right. Example: <table The sample web page below uses the HTML tags defined
browser. The most popular text editors are CuteHTML align="left"> in this section. To make this web page yourself, open your
(for PCs) or BBEdit (for Macs). <valign> HTML text editor and type in the following example exactly
Determines whether content
aligns with top, middle, or as it appears:
While WYSIWYG software can make web construction easy, bottom of table cells only.
it isn’t very precise and won’t help you understand HTML Example: <td valign="top"> <html>
or improve. The best way to learn—and the only way to get <head>
<border> Determines width in pixels of
precise control over your web design—is to learn to code <title>A New Web Page</title>
all table’s borders. Applies only
HTML by hand using text editors. to <table> tag. Example: <table </head>
border="1"> <body>
The Five Main Types of HTML Tags <font face="verdana" size="5" color="#FF0000">
There are five basic types of tags you need to know in <cellpadding> Sets distance in pixels between A <u>New</u> Web Page</font>
cell contents and boundaries.
order to create simple text-based web pages (to add photos <p>
Applies to <table> tag only. Ex-
and illustrations to web pages, see How to Add Images to ample: <cellpadding="5"> A sample <b>HTML</b> document created by <i>me</i>.
Web Pages). The five main types of tags are those used to: <br>
<cellspacing> Sets distance in pixels between (And some help from <a href="http://www.quamut.
• Style text cells. Applies only to <table> tag. com">Quamut</a>.)
Example: <cellspacing="5">
• Organize page elements </p>
• Separate page elements <p>
• Create links Tags Used to Separate Page Elements <table width="300" border="1" cellpadding="5"
• Insert images These tags are used to group or divide text. Each cellspacing="5">
creates a new line on your web page. <tr>
Tags Used to Style Text <td>
These tags are used to alter the appearance of text. The Code Function Cell 1.
effects of these tags, including fonts, sizes, colors, and </td>
<br /> Use this self-closing tag to create a
spacing, can be modified with more precision and variation line break. <td>
using CSS (see Cascading Style Sheets.) Cell 2.
<hr /> Use this self-closing tag to create a horizon- </td>
Code Function tal line that can be used to separate page <td>
elements. It can be modified with attributes
<b> Bolds text. <img src="../img/flowers.jpg" alt="flowers" />
such as “width,” “color,” and “align.”
</td>
<i> Italicizes text.
<p> Place <p> before and </p> after text to </tr>
<u> Underlines text. format the text into paragraphs. </table>
<font> Sets text’s typeface, size, and color. Sizes <hr width="300" align="left">
range in ascending order from 1–7. Colors Tags Used to Create Links </p>
are specified with hex codes. To add links to your web pages: </body>
Example: <font face="arial" size="2" </html>
color="#FF0000">)
• Know the URL of the page to which you’d like to link.
• Create an anchor tag that contains that URL. Save the file as sample.html. Then launch your web browser
Tags Used to Organize Page Elements and open sample.html from the File menu. The web page
HTML uses tables to organize text and images. A table Anchor Tags you just created should look like this:
is a framework that places content into horizontal rows An anchor tag uses the <a> tag along with the attribute
that contain cells. There are a few rules to remember href (which stands for hypertext reference). For instance:
about tables:
<a href = "http://www.quamut.com">Quamut</a>
www.quamut.com Building a Website

Think of CSS as a means of customizing HTML default Where to Find All the Available CSS Properties
settings to the settings of your choice. There are dozens of CSS properties that allow you to control
everything from fonts to border styles to the precise place-
An Example of a Real-World Application of CSS ment of onscreen page elements. You can research all the
Let’s say you’re publishing a long article on your website CSS properties online at www.w3.org.
that contains dozens of pages.
How to Use CSS Rules in Your HTML Files
• With HTML: Each time you start a new page, you To use CSS rules in HTML files, you must include a link tag.
would have to define how to display every element on The link tag associates your HTML file with your style sheet.
the page. For instance, you would have to specify the Below is the first portion of sample.html, the example HTML
size, color, and typeface of the article’s main font. document you created earlier in this guide, with a link tag
• With CSS: You can instead create a custom rule that added in the proper location within the <head> of the file.
specifies the main font’s traits and then reference that
rule when you use the main font on each page. <html>
<head>
The crucial difference between these approaches is that <title>A New Web Page</title>
Adding a DTD to Your HTML Documents with CSS, if you decide to change the main font’s appear- <link rel="stylesheet" type="text/css" href="sample.
All web pages must include at the very beginning of the ance, you need only change the rule in your style sheet. The css"/>
HTML code a few lines called a document type definition, change would then take effect on all of the article’s pages. </head>...
or DTD. A DTD ensures that a browser knows what version If you use just HTML, you have to change the HTML on each
of HTML your document contains, and therefore how to individual web page. The link tag tells your browser to look in sample.css to find
interpret and display your web pages. A standard DTD that the rules it should use to display your content.
you can use for all your web pages looks like this: The Contents of a Typical Style Sheet
A style sheet is a list of rules saved as plain text in a file with How to Apply CSS Rules to Page Elements in HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transi- the extension .css (for instance, sample.css). Here are three You can call, or apply, CSS rules to page elements in your
tional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- examples of different types of style sheet rules: HTML documents in two ways:
transitional.dtd">
• #titlefont {font-size: 10px; color: #BEBEBE;} • For rules preceded by a period: Use the word class
Place this DTD at the very top of all of your HTML docu- • .mainfont {font-size: 7px; color: #FF0000;} as an attribute in your HTML tags, followed by a value
ments, just before the first <html> tag. The contents of the • p {font-size: 5px; color: #000000;} equal to the name of the selector. For example, to
DTD will not display in the browser. apply the mainfont rule to the font of the main text in
Note that the most important difference among these three an article, you would include the following code in your
rules is the symbol that begins each rule. HTML document: <font class="mainfont">This text
Cascading Style Sheets (CSS) will now be seven pixels high and red.</font>
Cascading style sheets (CSS) work with HTML to stream- • Rules that you intend to use just once in your • For rules preceded by a pound sign: Use the word
line and enhance the process of creating web pages. document: These are preceded by a pound sign (#). id as an attribute in your HTML tags, followed by a
Rather than styling and organizing your content with many The rule that you would apply to the title font of your value equal to the name of the selector. For example,
small bits of HTML code, CSS allows you to centralize into article is an example of a rule that you would use just to apply the titlefont rule to the font of the title text in
one document—called a style sheet—the instructions for once per page. an article, you would include the following code in your
where to place your content and how to present it. • Rules that you intend to use more than once in HTML document: <font id="titlefont">This text
your document: These are preceded by a period. The will now be ten pixels high and gray.</font>
Why Use CSS? rule you apply to the main font of your article is an • For rules not preceded by a period or pound sign:
The many reasons to learn and use CSS include: example of a rule that you might use more than once Use the HTML tags as you normally would, without
per page. For instance, when an image breaks up the any further modification. For example, all paragraphs
• Flexibility and richness: CSS gives you more control main text of the article in your HTML code, you’ll need surrounded by <p> and </p> tags would be styled
over the structure and appearance of your documents to use your rule to specify the font at the beginning of according to the specs for “p” in your style sheet.
than HTML alone. the paragraph that immediately follows the image.
• Efficiency: CSS lets you control the appearance of text • Rules that apply to standard HTML tags: These Positioning Page Elements with CSS
throughout your website when you make changes to are preceded by neither a period nor a pound sign. Positioning page elements with HTML tables is difficult and
one central style sheet document. The rule’s name matches the name of the HTML tag imprecise since you can’t specify exactly where on the
• File size: CSS documents are small. Using CSS strips you wish to style. For instance, a rule named “p” screen you’d like each element to appear. CSS solves this
your HTML of dozens of tags, making your HTML would style the contents of all paragraphs (<p> tags) problem by allowing you to specify precisely where to posi-
documents smaller as well. throughout your document. tion elements down to the actual pixels, or dots, that make
• Page loading speed: Since CSS makes HTML files up computer screens.
smaller, web pages load faster. Note that you can choose any name you’d like when making For instance, if you wanted a light gray box behind all the
• No more tables: CSS allows you to place page your own CSS rules, but it’s always a good idea to choose content in sample.html, you would add a rule to your css file
elements with much more precision and fewer relevant names. If you’re styling all instances of an existing called “textbox” (or whatever you wish to call it), as in the
constraints than you can by using HTML tables. HTML tag, such as <p>, don’t give your rule a new name. following example:
• Compatibility: CSS ensures that your pages appear
the same on all platforms and in all browsers. What the Rules Above Mean and Do #textbox {position: absolute; left: 0px; top: 0px; height:
The first two CSS rules above control the appearance of the 200px; width: 300px; background-color: #BEBEBE;}
How CSS Works main font and title font used in an HTML document, hence
CSS does not replace HTML. Rather, it works with HTML by the selectors (names) “mainfont” and “titlefont.” Each rule’s The properties and values in this rule’s declaration,
letting you customize existing HTML tags according to the declaration, the text contained in braces ( { } ), contains explained in the following table, specify exactly where to
specifications you prefer. Here’s how the process works: properties, such as font size, that specify how to display the place the gray box:
page elements associated with the selector.
1. You create a style sheet document in which you specify Property Value Function
your preferences for how to position and display each • For mainfont: The rule is to make the font seven pixels
position absolute This indicates that the box
element included on your web page(s). Each entry in high and color it #FF0000 (the hex code for red).
should be placed exactly
your style sheet is called a rule. • For titlefont: The rule is to make the font 10 pixels where specified.
2. You reference the rule each time the elements to which high and color it #BEBEBE (the hex code for gray).
you’d like to apply the rule appear in your HTML code. left 0px This represents the pixel
The browser then knows to apply the specs in your rule The values of properties within a declaration are preceded along the horizontal plane
at which the text box should
to the element in your web page. by colons. Each property is followed by a semicolon.
start. 0px means the left-
most pixel on the screen.
www.quamut.com Building a Website

top 0px This represents the pixel you can browse and then buy. To find stock photography on • Fetch: The standard FTP software for Macs, it’s
along the vertical plane at the web, search for “stock photography” or refer to www. available at www.fetchsoftworks.com.
which the text box should
veer.com or www.gettyimages.com. Both sites offer some
begin. 0px means the top-
most pixel on the screen. free images. Logging In to Your Web Server with FTP
To log in to your server with FTP, you need the following
height 200px This represents the height of Creating Your Own Images information, all of which your web host will provide via email
the text box. Any image that can be converted to a digital format can be when you sign up for web hosting services:
width 300px This represents the width of published online. To create web-ready digital images, you
the text box. need a digital camera, which creates digital images on the • Server: The name of your web server; for instance,
spot, or a scanner, which digitizes existing print materials http://www.quamut.com
background #BEBEBE This represents the back- such as old photos, newspaper articles, or art. • User name: The name provided by your web host
color ground color of the text box • Password: Your FTP login password, as provided by
(in this case, gray).
How to Format Images for Your Web Pages your web host
Using <div> to Implement CSS Positioning Rules You’ll need to edit and format any image before publishing
The <div> tag (short for “division”) is an HTML tag used most it online. The three criteria you’ll need to consider when Once you get all of this information confirmed by your
often to position screen elements according to the instruc- editing images are: web host, start up your FTP software, enter the information,
tions in CSS rules. For instance, if you wanted to place the and click Connect.
gray text box used in the example above around all the • Dimension: The height and width of the image are
content in sample.html, you would place <div> tags that call measured in pixels. The maximum dimensions of any The Typical FTP User Interface
a CSS rule with positioning instructions for the text box just image should be 640 × 480 pixels. Most FTP software contains a main window split into two
inside your existing open and close <body> tags: • Resolution: The number of dots, or pixels, per inch vertical panes (the Mac program Fetch is one exception).
(dpi) in your image. Use 72 dpi, the resolution at which
<body> most monitors will display your image. • Left side: Lists the folders on your local hard drive
<div id="textbox"> • File size: The amount of data in your file, measured • Right side: Lists the directories on your web server
...[leave the intervening content here as is]... in kilobytes (k) or megabytes (megs). Keep your image
</div> files under 200k to make your pages load faster. Note You can browse through the directories on your hard drive
</body> that if you’re using a dialup modem to access your site, or server by clicking on the files.
</html> every 5k of file size you use adds about one second of
downloading time. Creating a Directory Structure with FTP
Your open <div> tag calls the “textbox” rule, which you Before you can upload any files to the server, you first have
would have had to add to your style sheet. Since you intend The most popular digital image editing software is Adobe to have directories into which you can upload them. Most
to use textbox just once, the open <div> tag contains the Photoshop, though you can find less expensive programs FTP programs allow you to create directories on your server
“id” property rather than the “class” property. by searching for “image editor” at www.download.com. in two ways:
You can now use this method to position all of the Once you’ve obtained image editing software, you’ll need to
elements in your web pages, such as images, paragraphs, resize and save images for optimal online viewing. • Manually: Use the same method you’d use to create
titles, and so on. Here’s a quick recap of the approach: folders on your local hard drive, such as right-clicking
Optimize Images for Your Web Pages your mouse and selecting New > Folder. This method
1. Surround elements you’d like to control with open and You can optimize the dpi, dimensions, and file size of your gives you more control.
close <div> tags. images by following the instructions below. Though these • Automatically: Your FTP program will create directories
2. Be sure your open <div> tag references the name of instructions apply to Photoshop, most other image editing on the fly if you upload entire folders to your web server.
a CSS rule in your style sheet that specifies where to software is similar. This method is best if the directory structure you intend
place your elements. These rules can also specify how to use for your site matches the hierarchy of file folders
to style the elements that you intend to place. 1. In the Image menu, select Image Size. you’ve created for your site on your hard drive. The new
2. A dialog box will appear where you can enter new directories will have the same names as the folders you
values for the width, height, and resolution (dpi). upload, and you’ll upload your folders and the files they
How to Add Images to Your 3. You should also be able to preview what file size your contain all at once.
Web Pages image will have after you’ve saved it.
4. Click OK. Uploading Your Website’s Files with FTP
Most web pages contain a mix of text and images, such as FTP software programs allow you to upload your folder or
photos, illustrations, or artwork. To include images on your Saving Images in the Correct File Format files in several ways:
pages, you need to: When you save your image files, you need to choose one of
the following formats: • Drag and drop: Drag entire folders or specific files
• Obtain or create your images from either location (local or remote) to the other.
• Format your images for publication on the web • GIF: Best used for logos or simple graphics with little • Double-click: Double-click on the specific file you
• Add images to your web pages using HTML and CSS color variation or shading (pronounced jiff ) want to move. The file will automatically move to the
• JPEG (or JPG): Best for photographs and other detailed opposite location (that being the server if it’s located
How to Obtain Images for Your Web Pages images (pronounced jay-peg) on your local hard drive, or vice versa).
If you’d like to use a specific image on your web page, you’ll • Click on buttons: Highlight folders, directories, or files,
need to use a clip art or stock photography resource or cre- and click on the Upload or Download buttons provided
ate the image yourself. How to Publish Your Website by the program. These buttons are typically shaped like
Once you’ve created a few web pages on your hard drive, arrows or contain arrow icons.
Clip Art Resources you’ll need to move those files onto the server where your
Clip art refers to decorative illustrations and graphics website will reside. Moving files to a server is done with FTP Transfer Modes
typically used to highlight text on a web page, in a print software called FTP, or file transfer protocol (see Website There are two transfer modes for uploading files: ASCII and
newsletter, or in another similar medium. If you’re starting Basics). FTP enables you to log in to your web server, cre- binary. The best mode to use depends on the type of files
a website on birdwatching, for example, you can easily find ate or modify directories, and upload (send) or download you’re uploading:
dozens of clip art images of birds and related imagery for (retrieve) files. Uploading your files to your web server is the
use in decorating your pages. To find clip art on the web, equivalent of publishing your work: your pages will be view- • ASCII: Use ASCII for HTML documents.
search for “clip art” or refer to www.clipart.com or www. able immediately by anyone with an internet connection. • Binary: Use binary for images and anything else that
clipartconnection.com. isn’t an HTML document.
Plenty of FTP software is available online for free or for a
Stock Photography Resources small cost. Most FTP programs will offer an auto-detect mode that will
Stock photography refers to photographs available for switch from ASCII to binary when needed. Use auto-detect
public use, either for a licensing fee or for free. Stock photo • WS-FTP: The standard FTP software for PCs, it’s mode if it’s available.
sites on the web typically have tens of thousands of images available at www.ipswitch.com/products/ws_ftp/
home/index.asp.

You might also like