You are on page 1of 18

Subject: ELECT3 - Web Design Date: 29 November2021

Name: Flores, John Paul G. Day: THS


[SURNAME, FIRSTNAME MI] [MWF] [THS] [WED] [SAT]

Section: CBET-25-503P Class No.: 14 Time: 03:00PM - 04:30PM

Task # 006

Topic # VII Formatting Tags

Sub-Topics:

A. HTML Text Formatting

HTML contains several elements for defining text with a special meaning

Example

This text is bold

This text is italic

This is subscript and superscript

HTML Formatting Elements

Formatting elements were designed to display special types of text:

➢ <b> - Bold text


➢ <strong> - Important text
➢ <i> - Italic text
➢ <em> - Emphasized text
➢ <mark> - Marked text
➢ <small> - Smaller text
➢ <del> - Deleted text
➢ <ins> - Inserted text
➢ <sub> - Subscript text
➢ <sup> - Superscript text

HTML <b> and <strong> Elements

The HTML <b> element defines bold text, without any extra importance.

Example

<b>This text is bold</b>

The HTML <strong> element defines text with strong importance. The content inside is typically displayed in
bold.

ELECT3 - Web Design Page | 1


Example

<strong>This text is important! </strong>

HTML <i> and <em> Elements

The HTML <i> element defines a part of text in an alternate voice or mood. The content inside is typically
displayed in italic.

Tip: The <i> tag is often used to indicate a technical term, a phrase from another language, a thought, a ship
name, etc.

Example

<i>This text is italic</i>

The HTML <em> element defines emphasized text. The content inside is typically displayed in italic.

Tip: A screen reader will pronounce the words in <em> with an emphasis, using verbal stress.

Example

<em>This text is emphasized</em>

HTML <small> Element

The HTML <small> element defines smaller text:

Example

<small>This is some smaller text.</small>

HTML <mark> Element

The HTML <mark> element defines text that should be marked or highlighted:

Example

<p>Do not forget to buy <mark>milk</mark> today.</p>

HTML <del> Element

The HTML <del> element defines text that has been deleted from a document. Browsers will usually strike a
line through deleted text:

ELECT3 - Web Design Page | 2


Example

<p>My favorite color is <del>blue</del> red.</p>

HTML <ins> Element

The HTML <ins> element defines a text that has been inserted into a document. Browsers will usually
underline inserted text:

Example

<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>

HTML <sub> Element

The HTML <sub> element defines subscript text. Subscript text appears half a character below the normal
line, and is sometimes rendered in a smaller font. Subscript text can be used for chemical formulas, like H2O:

Example

<p>This is <sub>subscripted</sub> text.</p>

HTML <sup> Element

The HTML <sup> element defines superscript text. Superscript text appears half a character above the
normal line, and is sometimes rendered in a smaller font. Superscript text can be used for footnotes, like
WWW[1]:

Example

<p>This is <sup>superscripted</sup> text.</p>

HTML Exercises
Exercise:

Add extra importance to the word "degradation" in the paragraph below.

<p>
WWF's mission is to stop the degradation of our planet's natural environment.
</p>

Submit Answer »
Tag Description
<b> Defines bold text
<em> Defines emphasized text
<i> Defines a part of text in an alternate voice or mood
<small> Defines smaller text

ELECT3 - Web Design Page | 3


<strong> Defines important text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
<mark> Defines marked/highlighted text

B. Computer Code Elements

HTML contains several elements for defining user input and computer codE

Example

<code>
x = 5;
y = 6;
z = x + y;
</code>

HTML <kbd> For Keyboard Input

The HTML <kbd> element is used to define keyboard input. The content inside is displayed in the browser's
default monospace font.

Example

Define some text as keyboard input in a document:

<p>Save the document by pressing <kbd>Ctrl + S</kbd></p>

Result:

Save the document by pressing Ctrl + S

HTML <samp> For Program Output

The HTML <samp> element is used to define sample output from a computer program. The content inside is
displayed in the browser's default monospace font.

Example

Define some text as sample output from a computer program in a document:

<p>Message from my computer:</p>


<p><samp>File not found.<br>Press F1 to continue</samp></p>

ELECT3 - Web Design Page | 4


Result:

Message from my computer:

File not found.


Press F1 to continue

HTML <code> For Computer Code

The HTML <code> element is used to define a piece of computer code. The content inside is displayed in the
browser's default monospace font.

Example

Define some text as computer code in a document:

<code>
x = 5;
y = 6;
z = x + y;
</code>

Result: x = 5; y = 6; z = x + y;

Notice that the <code> element does not preserve extra whitespace and line-breaks.

To fix this, you can put the <code> element inside a <pre> element:

Example

<pre>
<code>
x = 5;
y = 6;
z = x + y;
</code>
</pre>
Result:

x = 5;
y = 6;
z = x + y;

HTML <var> For Variables

The HTML <var> element is used to define a variable in programming or in a mathematical expression. The
content inside is typically displayed in italic.

ELECT3 - Web Design Page | 5


Example

Define some text as variables in a document:

<p>The area of a triangle is: 1/2 x <var>b</var> x <var>h</var>, where <var>b</var> is the base,
and <var>h</var> is the vertical height.</p>

Result:

The area of a triangle is: 1/2 x b x h, where b is the base, and h is the vertical height.

Chapter Summary

➢ The <kbd> element defines keyboard input


➢ The <samp> element defines sample output from a computer program
➢ The <code> element defines a piece of computer code
➢ The <var> element defines a variable in programming or in a mathematical expression
➢ The <pre> element defines preformatted text

HTML Exercises
Test Yourself With Exercises
Exercise:

Define the text "var person;" as programming code.

<p>Code example: var person; </p>

Submit Answer »

HTML Computer Code Elements

Tag Description
<code> Defines programming code
<kbd> Defines keyboard input
<samp> Defines computer output
<var> Defines a variable
<pre> Defines preformatted text

C. Quotation and Citation Elements

In this chapter we will go through the <blockquote>,<q>, <abbr>, <address>, <cite>, and <bdo> HTML
element

Example

Here is a quote from WWF's website:

ELECT3 - Web Design Page | 6


For nearly 60 years, WWF has been protecting the future of nature. The world's leading conservation
organization, WWF works in 100 countries and is supported by more than one million members in the
United States and close to five million globally.

HTML <blockquote> for Quotations

The HTML <blockquote> element defines a section that is quoted from another source.

Browsers usually indent <blockquote> elements.

Example

<p>Here is a quote from WWF's website:</p>


<blockquote cite="http://www.worldwildlife.org/who/index.html">
For 50 years, WWF has been protecting the future of nature.
The world's leading conservation organization,
WWF works in 100 countries and is supported by
1.2 million members in the United States and
close to 5 million globally.
</blockquote>

HTML <q> for Short Quotations

The HTML <q> tag defines a short quotation.

Browsers normally insert quotation marks around the quotation.

Example

<p>WWF's goal is to: <q>Build a future where people live in harmony with nature.</q></p>

HTML <abbr> for Abbreviations

The HTML <abbr> tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.", "Dr.", "ASAP",
"ATM".

Marking abbreviations can give useful information to browsers, translation systems and search-engines.

Tip: Use the global title attribute to show the description for the abbreviation/acronym when you mouse
over the element.

Example

<p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>

HTML <address> for Contact Information

The HTML <address> tag defines the contact information for the author/owner of a document or an article.

ELECT3 - Web Design Page | 7


The contact information can be an email address, URL, physical address, phone number, social media
handle, etc.

The text in the <address> element usually renders in italic, and browsers will always add a line break before
and after the <address> element.

Example

<address>
Written by John Doe.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>

HTML <cite> for Work Title

The HTML <cite> tag defines the title of a creative work (e.g. a book, a poem, a song, a movie, a painting, a
sculpture, etc.).

Note: A person's name is not the title of a work.

The text in the <cite> element usually renders in italic.

Example

<p><cite>The Scream</cite> by Edvard Munch. Painted in 1893.</p>

HTML <bdo> for Bi-Directional Override

BDO stands for Bi-Directional Override.

The HTML <bdo> tag is used to override the current text direction:

Example

<bdo dir="rtl">This text will be written from right to left</bdo>

HTML Exercises

Test Yourself With Exercises


Exercise:

Use an HTML element to add quotation marks around the letters "cool".

ELECT3 - Web Design Page | 8


<p>
I am so cool .
</p>

Submit Answer »

HTML Quotation and Citation Elements

Tag Description
<abbr> Defines an abbreviation or acronym
<address> Defines contact information for the author/owner of a document
<bdo> Defines the text direction
<blockquote> Defines a section that is quoted from another source
<cite> Defines the title of a work
<q> Defines a short inline quotation

D. HTML Tag

Example

Mark up a term with <dfn>:

<p><dfn>HTML</dfn> is the standard markup language for creating web pages.</p>

More "Try it Yourself" examples below.

Definition and Usage

The <dfn> tag stands for the "definition element", and it specifies a term that is going to be defined within
the content.

The nearest parent of the <dfn> tag must also contain the definition/explanation for the term.

The term inside the <dfn> tag can be any of the following:

1. Just as the content of the <dfn> element:

Example

<p><dfn>HTML</dfn> is the standard markup language for creating web pages.</p>

2. Or, with the title attribute added:

Example

<p><dfn title="HyperText Markup Language">HTML</dfn> is the standard markup language for creating
web pages.</p>

ELECT3 - Web Design Page | 9


3. Or, with an <abbr> tag inside the <dfn> element:

Example

<p><dfn><abbr title="HyperText Markup Language">HTML</abbr></dfn> is the standard markup language


for creating web pages.</p>

4. Or, with the id attribute added. Then, whenever a term is used, it can refer back to the definition with
an <a> tag:

Example

<p><dfn id="html-def">HTML</dfn> is the standard markup language for creating web pages.</p>

<p>This is some text...</p>


<p>This is some text...</p>
<p>Learn <a href="#html-def">HTML</a> now.</p>

Browser Support

Element

<dfn> Yes Yes Yes Yes Yes

Global Attributes

The <dfn> tag also supports the Global Attributes in HTML.

Event Attributes

The <dfn> tag also supports the Event Attributes in HTML.

Related Pages

HTML tutorial: HTML Quotation Elements

HTML DOM reference: DFN Object

Default CSS Settings

Most browsers will display the <dfn> element with the following default values:

Example

dfn {
font-style: italic;
ELECT3 - Web Design Page | 10
E. HTML Entities

Reserved characters in HTML must be replaced with character entities.

HTML Entities

Some characters are reserved in HTML.

If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags.

Character entities are used to display reserved characters in HTML.

A character entity looks like this:

&entity_name;

OR

&#entity_number;

To display a less than sign (<) we must write: &lt; or &#60;

Advantage of using an entity name: An entity name is easy to remember.


Disadvantage of using an entity name: Browsers may not support all entity names, but the support for
entity numbers is good.

Non-breaking Space

A commonly used entity in HTML is the non-breaking space: &nbsp;

A non-breaking space is a space that will not break into a new line.

Two words separated by a non-breaking space will stick together (not break into a new line). This is handy
when breaking the words might be disruptive.

Examples:

➢ § 10
➢ 10 km/h
➢ 10 PM

Another common use of the non-breaking space is to prevent browsers from truncating spaces in HTML
pages.

If you write 10 spaces in your text, the browser will remove 9 of them. To add real spaces to your text, you
can use the &nbsp; character entity.

ELECT3 - Web Design Page | 11


Tip: The non-breaking hyphen (&#8209;) is used to define a hyphen character (-) that does not break into a
new line.

Some Useful HTML Character Entities

Result Description Entity Entity


Name Number
non-breaking space &nbsp; &#160;

< less than &lt; &#60;


> greater than &gt; &#62;
& ampersand &amp; &#38;
" double quotation mark &quot; &#34;
' single quotation mark &apos; &#39;
(apostrophe)
¢ cent &cent; &#162;
£ pound &pound; &#163;
¥ yen &yen; &#165;
€ euro &euro; &#8364;
© copyright &copy; &#169;
® registered trademark &reg; &#174;

Note: Entity names are case sensitive.

Combining Diacritical Marks

A diacritical mark is a "glyph" added to a letter.

Some diacritical marks, like grave ( ̀) and acute ( ́) are called accents.

Diacritical marks can appear both above and below a letter, inside a letter, and between two letters.

Diacritical marks can be used in combination with alphanumeric characters to produce a character that is
not present in the character set (encoding) used in the page.

Here are some examples:

Mark Character Construct Result

̀ a a&#768; à
́ a a&#769; á
̂ a a&#770; â
̃ a a&#771; ã
̀ O O&#768; Ò
́ O O&#769; Ó
̂ O O&#770; Ô
̃ O O&#771; Õ

ELECT3 - Web Design Page | 12


F. HTML Styles

The HTML style attribute is used to add styles to an element, such as color, font, size, and more.

Example

I am Red

I am Blue

I am Big

The HTML Style Attribute

Setting the style of an HTML element, can be done with the style attribute.

The HTML style attribute has the following syntax:

<tagname style="property:value;">

The property is a CSS property. The value is a CSS value.

You will learn more about CSS later in this tutorial.

Background Color

The CSS background-color property defines the background color for an HTML element.

Example

Set the background color for a page to powderblue:

<body style="background-color:powderblue;">

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>

Example

Set background color for two different elements:

<body>
<h1 style="background-color:powderblue;">This is a heading</h1>
<p style="background-color:tomato;">This is a paragraph.</p>
</body>

ELECT3 - Web Design Page | 13


Text Color

The CSS color property defines the text color for an HTML element:

Example

<h1 style="color:blue;">This is a heading</h1>


<p style="color:red;">This is a paragraph.</p>

Fonts

The CSS font-family property defines the font to be used for an HTML element:

Example

<h1 style="font-family:verdana;">This is a heading</h1>


<p style="font-family:courier;">This is a paragraph.</p>

Text Size

The CSS font-size property defines the text size for an HTML element:

Example

<h1 style="font-size:300%;">This is a heading</h1>


<p style="font-size:160%;">This is a paragraph.</p>

Text Alignment

The CSS text-align property defines the horizontal text alignment for an HTML element:

Example

<h1 style="text-align:center;">Centered Heading</h1>


<p style="text-align:center;">Centered paragraph.</p>

Chapter Summary

➢ Use the style attribute for styling HTML elements


➢ Use background-color for background color
➢ Use color for text colors
➢ Use font-family for text fonts
➢ Use font-size for text sizes
➢ Use text-align for text alignment

ELECT3 - Web Design Page | 14


HTML Exercises

Test Yourself With Exercises


Exercise:

Use the correct HTML attribute, and CSS, to set the color of the paragraph to "blue".

<p =" ;">This is a paragraph.</p>

Submit Answer »

G. HTML Background Images

A background image can be specified for almost any HTML element.

Background Image on a HTML element

To add a background image on an HTML element, use the HTML style attribute and the CSS background-
image property:

Example

Add a background image on a HTML element:

<div style="background-image: url('img_girl.jpg');">

You can also specify the background image in the <style> element, in the <head> section:

Example

Specify the background image in the <style> element:

<style>
div {
background-image: url('img_girl.jpg');
}
</style>

Background Image on a Page

If you want the entire page to have a background image, you must specify the background image on
the <body> element:

Example

Add a background image for the entire page:

ELECT3 - Web Design Page | 15


<style>
body {
background-image: url('img_girl.jpg');
}
</style>

Background Repeat

If the background image is smaller than


the element, the image will repeat itself,
horizontally and vertically, until it reaches
the end of the element:

Example

<style>
body {
background-
image: url('example_img_girl.jpg');
}
</style>

To avoid the background image from


repeating itself, set the background-
repeat property to no-repeat.

Example

<style>
body {
background-image: url('example_img_girl.jpg');
background-repeat: no-repeat;
}
</style>

Background Cover

If you want the background image to cover the entire element, you can set the background-size property
to cover.

Also, to make sure the entire element is always covered, set the background-attachment property to fixed:

This way, the background image will cover the entire element, with no stretching (the image will keep its
original proportions):

Example

<style>
body {
background-image: url('img_girl.jpg');

ELECT3 - Web Design Page | 16


background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>

Background Stretch

If you want the background


image to stretch to fit the
entire element, you can set
the background-
size property to 100% 100%:

Try resizing the browser


window, and you will see
that the image will stretch,
but always cover the entire
element.

Example

<style>
body {
background-image: url('img_girl.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>

Learn More CSS

From the examples above you have learned that background images can be styled by using the CSS
background properties.

ELECT3 - Web Design Page | 17


References:

1. https://www.w3schools.com/html/html_computercode_elements.asp

2. https://www.w3schools.com/html/html_entities.asp

3. https://www.w3schools.com/html/html_formatting.asp

4. https://www.w3schools.com/html/html_images_background.asp

5. https://www.w3schools.com/html/html_quotation_elements.asp

6. https://www.w3schools.com/html/html_styles.asp

7. https://www.w3schools.com/tags/tag_dfn.asp

ELECT3 - Web Design Page | 18

You might also like