Cambodia Anita's blog Danny's blog Photos Resources
Skip to content

Primer 1: Text

A Quick Hint

When learning to code HTML you will often find yourself thinking, “I saw something really cool on Jane Doe’s website, how can I do that too?” The simplest way to figure that out is to direct your browser to their web page, right click anywhere on the page and select, “View Page Source” in FireFox or “View Source” on Internet Explorer. Try it out now with this web page to see what I’m talking about. Once you go through this primer,you will have the tools to decode most personal and small business websites. Unfortunately, corporate websites are often the result of complex computer generated code. This means trying to learn HTML by viewing the source of CNN.com is bound to be a fruitless endeavor.

Structural Tags

There are 7 basic structural HTML tags: Heading 1, Heading 2, Heading 3, Heading 4, Heading 5, Heading 6, and paragraph. While some web designers don’t use Headings 1 - 6, using them can be very helpful in structuring your the layout of your web page and will also help the visually impaired navigate your site. Some HTML gurus suggest that you refrain from using Headings 5 and 6 since they are smaller than the default font and can be difficult to read. The Paragraph tag is just that, a marker telling your computer the beginning and end of a paragraph. Here are examples of the 7 basic tags.

<h1>Heading 1</h1>

<h2>Heading 2</h2>

<h3>Heading 3</h3>

<h4>Heading 4</h4>

<h5>Heading 5</h5>
<h6>Heading 6</h6>

<p>Paragraph</p>

From the above you should note a few things. First, notes that according to XHTML conventions, every tag must be opened and closed. For example <p> must be followed by </p> for the browser to know what should be included in that tab. Otherwise, your formatting will spill over indefinitely until it is over ridden by a new tag. The main exception to this rule is the “line break” tag, <br />. The <br /> is typed at the place where you want a line break.

Two other tags which are indirectly needed (or at least very useful) for structuring text are <div> & <span>. As best as I can figure out, these two tags work pretty much the same except that <span> is usually used for formatting a small section (usually within a paragraph) and <div> is used for larger portions (including multiple paragraphs, tables, etc). In addition, <div> tends to cause a line break and therefore makes it a poor choice to use within a sentence or paragraph. For example …

In the beginning Danny God created the heavens and the earth. In the beginning <span style=”text-decoration: line-through;”>Danny</span>God created the heaven and the earth.


In the beginning

Danny

God created the heavens and the earth.

In the beginning <div style=”text-decoration: line-through;”>Danny</div> God created the heaven and the earth.

Common Style Tags

In addition to the structural tags above, there are many other ways you can tweak your formatting. Below is a table demonstrating some of the more common ones.

Bold <b>Bold</b><br />
Strong <strong>Strong</strong><br />
Emphasis <em>Emphasis</em><br />
Italics <i>Italics</i><br />

Align Right

<div align=”right”>Align Right</div>

Align Left

<div align=”left”>Align left</div>

Align Center

<div align=”center”>Align Center</div>

Justified

<div align=”justify”>Justified</div>

Color - method 1 <font color=”red” > Color </font>– method 1
Sample Superscript Sample <sup>Superscript</sup>
Sample Subscript Sample<sub>Subscript</sub>
Size <font size=”+2″>Size</font>

<hr align=”center” width=”80%” />

As I said, the above merely shows some of the more common ways of formatting text and was not meant to be a comprehensive list. I purposefully did not demonstrate underlining since I believe this should be avoided in HTML. By default, HTML notes a hyperlink by underlining it and changing the text color (typically to blue). Therefore, underlining text may confuse people into thinking your regular text is a link.

Also note that in the above chart, I often had to choose an arbitrary value to demonstrate the formatting tag. For example, the size tag has a wide range:

-5 -4 -3 -2 -15 4 3 2 1+5 +4 +3 +2 +1 etc.

Likewise, there are a whole range of colors that you can select for your text, background, border, etc216 to be exact.

Refer to the chart below [from from HTML Goodies] to find the code for the color that you want to use. Alternatively, you can use Pixie to find the HTML code of any color that you like on your computer (from another webpage, a photo, a drawing, etc).

FFFFFF FFFFCC FFFF99 FFFF66 FFFF33
FFFF00 CCFFFF CCFFCC CCFF99 CCFF66
CCFF33 CCFF00 99FFFF 99FFCC 99FF99
66FFFF 99FF66 99FF33 66FFCC FFCCFF
99FF00 33FFFF FFCCCC 33FFCC 00FFFF
66FF99 FFCC99 66FF66 66FF33 00FFCC
66FF00 33FF99 FFCC66 FFCC33 CCCCFF
33FF66 33FF33 00FF99 FFCC00 33FF00
00FF66 00FF33 00FF00 CCCCCC CCCC99
99CCFF CCCC66 CCCC00 CCCC33 99CCCC
FF99FF 99CC99 66CCFF FF99CC 99CC66
66CCCC 99CC33 00CCFF 33CCFF 99CC00
FF9999 66CC99 FF9966 66CC66 33CCCC
CC99FF 00CCCC FF9933 FF9900 66CC33
66CC00 33CC99 00CC99 CC99CC 33CC66
00CC66 CC9999 FF66FF 33CC33 33CC00
CC9966 00CC33 9999FF 00CC00 CC9933
CC9900 FF66CC 9999CC FF6699 999999
6699FF FF6666 CC66FF 999966 6699CC
999933 FFCC33 FF6600 FF33FF 3399FF
999900 669999 CC66CC 0099FF FF33CC
3399CC CC6699 669966 FF00FF 339999
669933 669900 FF3399 0099CC 9966FF
CC6666 009999 CC6633 CC6600 339966
FF00CC FF3366 009966 CC33FF FF3333
339933 009933 9966CC FF3300 FF0099
339900 009900 6666FF CC33CC FF0066
996699 FF0033 FF0000 CC00FF CC3399
996666 6666CC 996633 996600 3366FF
CC3366 CC00CC 9933FF 0066FF 666699
CC3333 CC3300 3366CC CC0099 9933CC
666666 666633 0066CC 9900FF 666600
CC0066 336699 993399 CC0033 6633FF
336666 006699 CC0000 993366 9900CC
336633 006666 336600 6633CC 3333FF
006633 993333 993300 6600FF 990099
006600 0033FF 663399 009966 3333CC
663366 6600CC 990033 0033CC 990000
3300FF 663333 663300 660099 0000FF
333399 3300CC 003399 333300 660066
333333 003366 0000CC 660033 333300
660000 330099 003333 003300 000099
330066 330033 000066 330000 000033
000000

Lists

At some point you may desire to create a list using HTML. There are two ways to do this … the easy way and the hard way. The easy way is to use ordered list <ol> and unordered list <ul> tags. The hard way is to manually make each individual bullet. Let’s take a look at a samples lists using the <ol> and <ul> tags.

Ordered List
  1. one
  2. two
  3. three
Ordered List
<ol>
<li>one</li>
<li>two</li>
<li>three</li>
</ol>

Unordered List

  • one
  • two
  • three
Unordered List
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>

Okay, enough about plain text. The purpose of HTML is to develop hyperlinked documents so let’s learn about links!