Kent Pitman

Kent Pitman
Location
New England, USA
Title
Philosopher, Technologist, Writer
Bio
I've been using the net in various roles—technical, social, and political—for the last 30 years. I'm disappointed that most forums don't pay for good writing and I'm ever in search of forums that do. (I've not seen any Tippem money, that's for sure.) And I worry some that our posting here for free could one day put paid writers in Closed Salon out of work. See my personal home page for more about me.

JUNE 19, 2009 6:18PM

A Quick Intro to HTML for Open Salon Users

Rate: 33 Flag

Anyone who has gone into the Open Salon HTML editor will note that HTML text, sometimes called a markup language, is marked up by things called tags. There is a start tag marking the start of a piece of text and an end tag marking the end. For example, this paragraph contains <p> at the start of it and </p> at the end of it. The entire item, “<p>Anyone who has...</p>” is called an element, in this case a p element (or “paragraph element” because p tags are used to mark a paragraph).

Element Content

The stuff between the start tag and the end tag of an element is the content. In this expression:

<b>some text</b>

In this, the text “some text” is the content of the b element (or “bold element”).

Some popular markup

  • Use <p>text of a paragraph</p> to mark a paragraph.

  • Use <b>bold</b> for bold.

  • Use <i>italic</i> for italic.

  • Use <b><i>bold italic</i></b> for bold italic.

    That is, combine the bold and italic markup.

Examples of Marked Up Content

Here's an example:

This paragraph illustrates some markup. Two words are in bold. Another three words are in italic. And, finally, four words are in bold italic.

The previous paragraph was set by this markup:

<p>
This paragraph illustrates some markup.
<b>Two words</b> are in bold.
<i>Another three words</i> are in italic.
<b><i>And, finally, four words</i></b> are in bold italic.
</p>

Note that the paragraph is itself a p element. It contains two b elements (starting with the start tag <b> and continuing to the end tag </b>) and two i elements (<i>...</i>). The first b and i elements are by themselves, while the second b element contains an i element.

Element Attributes

Some elements allow attributes, which are special named values that are associated with the element. For example, an “a” attribute (“a” is short for “anchor”, by the way) takes an “href” (or “hypertext reference”) attribute to tell you what's anchored to the “a” element at the other end. This text is an example, and is created by this HTML markup:

<a href="http://www.nhplace.com/kent/">This text</a>

That creates an anchor that has a URL for my home page associated with it.

For example, a p element can have an attribute that says how to align the paragraph (left justified, center justified, or right justified). Consider this paragraph:

This paragraph is centered.

The previous paragraph uses this markup:

<p align="center">This paragraph is centered.</p>

The following is another way to do the same thing, but it requires knowledge of CSS (explained later in this article, and in another I wrote).

<p style="text-align: center;">This paragraph is centered.</p>

Special Cases

In HTML, there are a few special case bits of markup that need no content and that do not require an end tag (in fact some browsers don't like end tags for these). These are hr, br, and img.

  • An “hr” element is used to introduce a horizontal rule (a “rule” is typesetting jargon for a straight line). One writes only “<hr>” and never “<hr></hr>” since there is never any content to a horizontal rule.

  • A “br” element is used to break a line without starting a new paragraph. (This is sometimes called a “soft return” by typographers.) One writes only “<br>” and never “<br></br>” since there is never any content to a break.

  • An “img” element is used to insert an image. One writes only “<img ...>” and never “<img ...></img>” since there is never any content to an image (in the formal sense that HTML means the word content—the picture part is all specified using attributes, which I've elided here by the “...” for brevity).

For various reasons of history and compatibility, though, it is preferable for each of these three cases to terminate the “br”, “hr,” or “img” element not with a greater-than sign (>) but rather with a three character sequence: a space, a slash (/), and greater-than sign (>). So it's preferable to write “<br />” or “<hr />” or “<img ... />” (Ending a start tag with “ />” is a promise that you will not be putting any content or end tag for the element. Never use “/>” if you are planning to put an end tag for that element.)

Images

To insert an image, such as:

pumpkin

one must use an img element, providing several attributes. Most editing programs will help you set this stuff up so you don't have to do it manually. But the above picture was comes from doing:

<img src="http://open.salon.com/files/pumpkin-face1221728008.gif" alt="pumpkin" width="54" height="52" />
  • The src attribute specifies the source of the image data.

  • The alt attribute specifies text to show if a user uses a text-only web-browser. (This is also used for people who are sight-impaired so that a program can read aloud a description of what sighted people are seeing. And it is used in some situations as the text that hovers over the top of the picture when you wave your mouse over the picture.

  • It's useful to provide at least the width if not also the height. By default, if you give no units, the units are pixels (the size of a single little dot on your display screen or printer). You can make this explicit by saying 54px instead of just 54 if you like that kind of thing. In some cases, you may prefer to use other units like inches, as in 0.5in to mean a half inch.

Character Entities

The character ampersand (&) can be followed by certain magic names of characters, with the name terminated by a semicolon. (The semicolon won't appear in your final text but you have to put it in the HTML source.)

  • Use &lt; to insert a “less than” sign: <
    Use &gt; to insert a “greater than” sign: >

  • Use &amp; to insert an “ampersand”: &

  • Use &mdash; to insert an “em dash”: —

  • Use &ldquo; and &rdquo; to insert left and right doublequotes (the fancy kind): “foo” (not "foo")
    Use &lsquo; and &rsquo; to insert left and right single quotes: ‘foo’ (not `foo')
    Use &laquo; and &raquo; to insert left and right angle quotes: «foo» (not <<foo>>)
    Note that &rsquo; is also the pretty apostrophe character: can’t (not can't)

  • Use &nbsp; to insert a “non-breaking space” character (a space that does not permit a line break). So if you want your name to always appear as Joe Plumber on one line, and never as Joe
    Plumber
    broken across lines, use Joe&nbsp;Plumber. This will assure that if the pair of words appears near the end of a line, it either all appears on one line or all on the next line. (In fact, &nbsp; represents a non-space, so HTML tries not to break there, but it's a non-space that looks just like a space.)

  • Characters with accents are possible to write with this as well. They each have names, so you have to learn the names of things you care about. But, for example, &eacute; will get you é, a letter e with an acute accent over it. &ntilde; will get you ñ, a letter n with a tilde over it. It's case-sensitive (the difference between upper- and lowercase matters) so that &Eacute; will get you É and &Ntilde; will get you Ñ. There is an official full list of character entities but I find it hard to read. There are other lists that are not official but easier to read.

You can find a complete description of the entire HTML specification (version 4) at the w3.org web site. They maintain the standards for many of the protocols and markup languages that describe how the web operates.

Fancier stuff with CSS

There is a special additional stuff you can do using something called CSS (Cascading Style Sheets). CSS is a whole extra language for specifying layout and can be piggy-backed onto HTML text by using a style attribute on various elements. You don't have to understand all of CSS to know how to do some cool things. Just take a look at some examples:

Use <p style="text-indent: 36pt;">Your text here.</p> to create a paragraph that has 36 points of indentation in the first line only. That's half an inch—there are 72 points to an inch. You could say 0.5in if you prefer, but typographers prefer points so they can often specify amounts using simple integers (e.g., 36pt) rather than fractions (e.g., 0.5in).

Use <p style="color: blue;">Your text here.</p> to put the text of your paragraph in blue.

Or combine several effects:
<p style="background: silver; color: red; padding: 12pt;">
Your text here.</p>

will change the background to silver and the text color to red, and will also add 12 points (a sixth of an inch) of padding around the edge between the text and the border;


If you got value from this post, please "rate" it.

Your tags:

TIP:

Enter the amount, and click "Tip" to submit!
Recipient's email address:
Personal message (optional):

Your email address:

Comments

Type your comment below:
Heh. I will gladly add my endorsement, thin as it is, to the CSS tutorial, and to everything above, which I use almost daily. HTML is... just necessary.

Thanks for the clear post.
This looks insanely useful but I'm too cross-eyed by this time of day to digest it! But I've bookmarked it to look at some AM when I've just had my coffee and am bright-eyed and bushy tailed....
Excellent tutorial Kent, really well done and should be do able even for some of those who "are afraid." I needed a reminder too because not using html when you can is like not speaking Italian when you go to Rome, why would you do that?

THANKS!
Thanks for sharing your vast knowledge in another excellent tutorial on how to "pimp" my blog.
Bowing down! Thank you! Thank you!
Thanks, Kent! This might actually help...now if I can only figure out how to print it out...
Terrific! Actually, what I'm learning about HTML seems very logical. It's when I get in whatever thing it is OS uses to automatically format stuff that I get confused. Luckily, I have a 'puter wizard in the next office. Good thing we have you here!
Saturn, thanks for the endorsement!

Silkstone, there's no hurry. It's not only on my regular blog list but it's under my links list, so you can find it later if you need to.

Ablonde, yep, it's useful in its place. And now the reference is handy when needed.
Thank you, Kent. This is useful. I recently received a request for information on HTML from another OSer and referred to both you and Rob St. Amant because you had both previously posted tutorials like this.

RATED
uh, I had a thought just as I hit the "Post this comment" button; which of these elements do not work in comments? It seems that there are differences in the HTML editors for the various formats here on OS.
And by the way, "pimping" your blog isn't the same as blog whoring. It's just an expression that denotes making things look as gorgeous and stylish as they possibly can be. Which your tips will help to do!
Worse than that, Rick. The various editors each strip DIFFERENT amounts of HTML out of what you write. What's allowed in a comment is different than in posts which is different than full HTML. But what's allowed in your bio is different than all of those. And OS mail uses a different subset, too! It's very very frustrating in ways I take no responsibility for. OS has arranged some of the issues that way...
I will definitely have to read this a few times and practice, practice, practice! As with most things I imagine its easier than it sounds.
I can promise I will be using this in the near future. Amazing all of the crazy stuff you can do with these computer thingys. Still scratching my head, but I think I can grasp this. Thanks Kent. Very helpful.

Ps. You totally lost me on the above answer to Rick. Wow.
Kent, I think my best bet is to add this to my bookmarks and try for a read and study day tomorrow. I thank you for this post. It looks like I might learn something very good here. I am just tired right now. It has been a very long, hot day here.
Rated and bookmarked.
Ya ha! Thanks, Kent, for the tutorial. To anyone who reads this, it's good to try one new thing at a time. After a while, it's second nature.

I'm going to start doing paragraphs, next.

Rated, bookmarked and ZumaPick.
THANK YOU!!! I can't believe it, everything in one post. Feels like I owe you the $1,300.00 price tag that The Art Institute charges for this kind of instruction. Copied and pasted into my Hard Drive for all of my online commentary eternity
Kent,
You have a wonderful gift of being able to explain and instruct when it comes to topics that many of us feel intimidated just hearing the name of.

You’re a wonderful and generous contributor to OS and I’m grateful to call you a “friend” ... or is that “favorite” now? Oh heck you’re absolutely both.

Rated and appreciated
Does this work> for comments?
It looks like it would have, if I'd done it right. Thanks so much for this.
Ali, no one paid me to write any of this. It's volunteer labor. I am happy to take questions but not insults. I'm more likely to take the post down when people talk to me in an entitlement kind of way.
thank you, thank you, thank you
I trust that somewhere, somehow, you are paid to provide information Kent. Whatever you get, it ain't enough! Thanks
Serious content. Seriously rated. I'm a little scared right now because you think I will get this. I am honored that you may believe in me, however, here's the thing. We celebrated FD early. All afternoon and evening, as a matter of fact and I was in charge of the Margarita's. Enough said.

This is a very heady post and one I should take very seriously and give my full attention. Frankly, it scares me right now because I am in no shape to take such a tecchnical class after so many Margarita's. A bar tending class, maybe, but not this one.

Kent, I promise to come back to this a make this up to you! This is a valuable post and I have a lot to learn here. Up to this point, I am certain that I have failed the "os user manual." Highly rated. *****
Cathy, it will help to have a specific goal of something you want to do. Maybe something simple, just to get confidence. That's what several have suggested. If you have questions just ask. It might indeed be hard, and I might be terrible at explaining it. But I might not, and you might do fine. So don't sell yourself short, just give it a shot and ask questions if you get stuck.
Kent, this is wonderful! Thank you for taking the time to explain HTML to all of us. I need to memorize much of it, but I am also marking it as a reference. this is very kind of you......
I'll give you a bump and thanks.
give it another try