CHAPTER 3 - HTML - Formatting
CHAPTER 3 - HTML - Formatting
CHAPTER 3 - HTML - Formatting
Remember that your Web site either provides entertainment and/or information; thus enticing your viewers is one main
concern therefore supplying your content with design is a major boost. But do not exaggerate in doing so. Remember that
there is always beauty in simplicity.
❖ Typography – appearance and arrangement of the characters that make up your text.
❖ Typeface – the actual appearance, examples are Times New Roman, Arial, etc.
❖ Type style – this is the variations given to the text such as boldface, italic, regular, etc.
❖ Font – combination of typeface and type style.
1|Page
Web Page Programming (Using HTML and JavaScript)
Preformatting Text
You can preformat text by using the Preformat Tag pair<pre></pre>.
2|Page
Web Page Programming (Using HTML and JavaScript)
If you use a word processor, you must be familiar with the ability to make text bold, italicized, or underlined; these are ju st
three of the ten options available to indicate how text can appear in HTML and XHTML.
Bold Text
Anything that appears within <b>...</b> element, is displayed in bold as shown below:
<p>The following word uses a <b>bold</b> typeface.</p>
Italic Text
Anything that appears within <i>...</i> element is displayed in italicized as shown below:
<p>The following word uses a <i>Italicized</i> typeface.</p>
Underlined Text
Anything that appears within <u>...</u> element, is displayed with underline as shown below:
<p>The following word uses a <u>Underlined</u> typeface.</p>
Strike Text
Anything that appears within <strike>...</strike> element is displayed with strikethrough, which is a thin line through the text
as shown below:
<p>The following word uses a <strike>Strikethrough</strike> typeface.</p>
Monospaced Font
The content of a <tt>...</tt> element is written in monospaced font. Most of the fonts are known as variable -width fonts
because different letters are of different widths (for example, the letter 'm' is wider than the letter 'i'). In a monospaced font,
however, each letter has the same width.
<p>The following word uses a <tt>monospaced</tt> typeface.</p>
Superscript Text
The content of a <sup>...</sup> element is written in superscript; the font size used is the same size as the characters
surrounding it but is displayed half a character's height above the other characters.
<p>The following word uses a <sup>superscript</sup> typeface.</p>
Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the same as the characters surrounding it,
but is displayed half a character's height beneath the other characters.
3|Page
Web Page Programming (Using HTML and JavaScript)
Inserted Text
Anything that appears within <ins>...</ins> element is displayed as inserted text.
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
Deleted Text
Anything that appears within <del>...</del> element, is displayed as deleted text.
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
Larger Text
The content of the <big>...</big> element is displayed one font size larger than the rest of the text surrounding it as shown
below:
<p>The following word uses a <big>big</big> typeface.</p>
Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than the rest of the text surrounding it as
shown below:
<p>The following word uses a <small>small</small> typeface.</p>
Grouping Content
The <div> and <span> elements allow you to group together several elements to create sections or subsections of a page.
For example, you might want to put all of the footnotes on a page within a <div> element to indicate that all of the elements
within that <div> element relate to the footnotes. You might then attach a style to this <div> element so that they appear
using a special set of style rules.
<!DOCTYPE html>
<html>
<head>
<title>Div Tag Example</title>
</head>
<body>
4|Page
Web Page Programming (Using HTML and JavaScript)
<!DOCTYPE html>
<html>
<head>
<title>Span Tag Example</title>
</head>
<body>
<p>This is the example of <span style="color:green">span tag</span> and the
<span
style="color:red">div tag</span> alongwith CSS</p>
</body>
</html>
5|Page
Web Page Programming (Using HTML and JavaScript)
Images or Graphics
You can add image to your Web page with the use of <img> tag. The <img> tag supports several attributes, but the scr=
attribute is the one that specifies the name and location of the image.
You can create an image from Adobe Photoshop, MS Paint or any image-editing programs. You should save your image in
a JPEG format and compress the image so that loading time will be fast. You can reduce image size by saving your file for
the web. You can also use GIF format for logos and other images that include text and graphics.
Attribute Table for <img>
ATTRIBUTE NAME DEFINITION EXAMPLE
src Indicates the image to be inserted. This attribute is a must <img src=”picture.jpeg”>
alt Indicates the alternative text or the text that appears when the <img src=”picture.jpeg”
mouse hovers over the image and/or when the image can not alt=”Can not display”>
be displayed.image to be inserted.
name Assigns a name to the image. <img src=”picture.jpeg”
name=”picture.jpeg”>
border Indicates the width of the border around the image in pixels. <img src=”picture.jpeg”
By default, the value is zero (doesn’t have a border) however, border=”3”>
images used as hyperlinks have borders by default; use
border=”0” to remove it. <img src=”picture.jpeg” >
height Indicates the height of the image in pixels. If not the actual <img src=”picture.jpeg”
height is specified, the image will be scaled to fit. height=”300”>
width Indicates the width of the image in pixels. If not the actual <img src=”picture.jpeg”
width is specified, the image will be scaled to fit. width=”300”>
align Indicates the horizontal alignment of image. <img src=”picture.jpeg”
align=”center”>
vspace Sets the vertical space in pixels above and below the image. <img src=”picture.jpeg”
vspace=”6”>
hspace Sets the horizontal space in pixels beside the image. <img src=”picture.jpeg”
hspace=”6”>
lowsrc Indicates the image to be loaded before the actual image <img src=”picture.bmp”
6|Page
is loaded. Smaller images or of lower resolution is usually used lowsrc=” picture.jpeg”>
here.
hspace=”6”>
Web Page Programming (Using HTML and JavaScript)
<!DOCTYPE html>
<html>
<head>
<title>Images</title>
</head>
<body>
<img src="firefox.jpg" width="10%"
height="20%">Image without horizontal and vertical space
<p>
<img src="ie.jpg" width="10%"
height="20%" hspace="35">Image with horizontal space
<p>
<img src="googlechrome.jpg" width="10%"
height="20%" vspace="35">Image with vertical space
<p>
</body>
</html>
7|Page
Web Page Programming (Using HTML and JavaScript)
<!DOCTYPE html>
<html>
<head>
<title>Graphic-Hyperlink</title>
</head>
<body>
<img src="icct.jpg"><br>
<p>
<a href="https://www.facebook.com/"><img src="sfblink.jpg"></a><p>
<a href="https://twitter.com/explore">
<img src="stwitlink.jpg"></a><p>
<a href="https://www.youtube.com/"><img src="sytlink.jpg"></a><p>
</body>
</html>
8|Page
Web Page Programming (Using HTML and JavaScript)
9|Page