Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 36

HTML

Create your own Website


Chapter 3
Paragraphs, Styles, Formatting and Colors
REVIEW
Best Web Safe Fonts for HTML and CSS
Arial (sans-serif) SAMPLE
Verdana (sans-serif)
Helvetica (sans-serif)
Tahoma (sans-serif)
Trebuchet MS (sans-serif)
Times New Roman (serif) SAMPLE
Georgia (serif)
Garamond (serif)
Courier New (monospace)
Brush Script MT (cursive)
HTML
PARAGRAPHS
HTML Paragraphs
A paragraph always starts on a new line, and is usually a block of text.

The HTML <p> element defines a paragraph.

A paragraph always starts on a new line, and browsers automatically add


some white space (a margin) before and after a paragraph.

Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
HTML Display
You cannot be sure how HTML will be displayed.

Large or small screens, and resized windows will create different results.

With HTML, you cannot change the display by adding extra spaces or extra
lines in your HTML code.

The browser will automatically remove any extra spaces and lines when the
page is displayed:
HTML Display example
<p> <p>
This paragraph This paragraph
contains a lot of lines contains a lot of spaces
in the source code, in the source code,
but the browser but the browser
ignores it. ignores it.
</p> </p>
HTML Horizontal Rules
he <hr> tag defines a thematic break in Example
an HTML page, and is most often <h1>This is heading 1</h1>
displayed as a horizontal rule.
<p>This is some text.</p>
<hr>
The <hr> element is used to separate
content (or define a change) in an HTML <h2>This is heading 2</h2>
page: <p>This is some other text.</p>
<hr>
HTML Line Breaks
The HTML <br> element defines a line Example
break. <p>This is<br>a paragraph<br>with
line breaks.</p>
Use <br> if you want a line break (a new
line) without starting a new paragraph:
The Poem Problem
This poem will display on a single line:

Example
<p>
My Bonnie lies over the ocean.

My Bonnie lies over the sea.

My Bonnie lies over the ocean.

Oh, bring back my Bonnie to me.


</p>
Solution - The HTML <pre> Element
The HTML <pre> element defines preformatted text.

The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces
and line breaks:
Example
<pre>
My Bonnie lies over the ocean.

My Bonnie lies over the sea.

My Bonnie lies over the ocean.

Oh, bring back my Bonnie to me.


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

Example
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.

Example
<p style=“color:blue;”>This is blue</p>
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>
Background Color
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>
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
Text Size
The CSS font-size property defines the text size for an HTML element:

Example
<h1 style="font-size:150%;">This is a heading</h1>
<p style="font-size:300%;">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>
HTML TEXT
FORMATTING
Text Alignment
HTML contains several elements for defining text with a special meaning.

Example
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.

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.

Example
<i>This text is italic</i>

The HTML <em> element defines emphasized text. The


content inside is typically displayed in italic.

Example
<em>This text is emphasized</em>
HTML <i> and <em> Elements
Tip: The <i> tag is often used to indicate a technical term, a
phrase from another language, a thought, a ship name, etc.

Tip: A screen reader will pronounce the words in <em> with an


emphasis, using verbal stress.
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 <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 COLORS
HTML Colors
HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA, or HSLA values.

https://htmlcolorcodes.com/color-names/
Color Names
In HTML, a color can be specified by using:
Background Color
You can set the background color for HTML elements:

Example
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">Lorem ipsum...</p>
Text Color
You can set the color of text:

Example
<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>
Border Color
You can set the color of borders:

Example
<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>
Codes for output
• <hr> • bold and strong
• <br> • italic and emphasize
• <pre> • small
• background color • mark
• font family • subscript
• font color • superscript
• text size • border
• text alignment

You might also like