Chapter 2: Understanding HTML

Basic Text Formatting in HTML


[ Comments ] [ Copyright ] [ Chapter contents ] [ Book contents ]


HTML is the product of a collision between two schools of thought about how to create a generic text formatting language.

First let's look at the uncontroversial stuff. The basic elements of an HTML document are chunks of text, aggregated into paragraphs. Because HTML is rendered to fit different-sized windows on different systems, all HTML browsers do their own word-wrapping to fit the width of the line to the width of the window. A space character or carriage return in an HTML document is basically interpreted by a browser as an opportunity to insert a space or a line break at its own discretion. If you just type text in and separate your paragraphs with blank lines, the browsers will happily ignore the blanks and concatenate your text into one monster paragraph.

HTML gives us a tag, <P>, to indicate a new paragraph. A paragraph consists of text enclosed in the tag <P> ... </P>. However, in practice, the </P> is not necessary; the paragraph is implicitly closed by the start of the next paragraph or heading element. For example:


<BODY>

<TITLE>My first document</TITLE>

This is my first paragraph in an HTML document. As you can see, 
there isn't much to it.

<P>

And this is a separate paragraph.

</BODY>

A browser will display that text like this.

It's worth noting that most browsers render paragraphs by leaving a gap between them. If you want to simply end a line at a given point, but not start a new paragraph, there's a line break tag <BR>, which just breaks the line but doesn't add any vertical space.

Of course, paragraphs of text are all very well, but how do we highlight topic headings and titles?

HTML provides six levels of headings. Heading tags go in pairs:


<H1>This is a level one heading</H1>

<H2>This is a level two heading</H2>

<H6>This is a level six (very small!) heading</H6>

It's a good idea to use heading levels sparingly, and to start with an H1 and work down from there. For example, a simple monograph might look a bit like this:


<HTML>

<HEAD>

<TITLE>Some appropriate title</TITLE>

</HEAD>

<BODY>

<H1>Diagnosis of familial hypobetalipoproteinaemia in 
neonates</H1> 

<!-- abstract--> 

This disease is an extremely rare inborn error of metabolism. 
Less than fifty cases have been dianosed world-wide. It was 
first characterised in the 1950's by Bassen and Kornzweig (qv) 
and is sometimes referred to as the Bassen-Kornzweig syndrome. 

<P>

This article discusses the differential diagnosis of FHBP in 
neonates, with particular reference to ...

<!-- end of abstract-->

<HR>

<H2>Signs and Symptoms</H2>

<!-- what it looks like at first -->

The abetalipoproteinaemic infant typically presents with a 
generalized failure to thrive.

Atypical retinitis pigmentosa is not an initial presenting 
condition in most cases ...

<!-- end of symptoms -->

</BODY>

</HTML>

The structure of this document is explicit; you can get away without the <HTML>, <HEAD>, and <BODY> tags in real life, and many documents do in practice omit them.

Separate blocks of text are distinguished by heading tags or paragraph tags; because the text following a heading "close" tag is not part of the heading itself, an implicit new paragraph follows each heading.

The <HR> tag after the introduction inserts a horizontal rule in the document-a line that splits the first section off from those following it.

When you view this file using a web browser (for example, Netscape 1.1), it looks something like this:

[[ Graphic: CH2-Example1.pict ]]

There should be nothing particularly confusing about the system so far; the HTML simply consists of text containing formatting directives. The controversy sets in when we try to emphasize text. Because different browsers have different fonts and radically different appearences, there is no guarantee that this document will look the same when viewed on different computers. How, then, do we go about emphasizing text?


[ Comments ] [ Copyright ] [ Chapter contents ] [ Book contents ]