How to format text in HTML

28.2.1. How to format text in HTML

To format a text in bold, you can use the <b> tag (deprecated in XHTML, use CSS instead, see Section 14.12, Section 28.3!). We recall that in HTML in most cases you have to open and close the tag. Thus, the code

<b>Hello</b> World

means that the word "Hello" shall be in bold face, while the rest of the sentence will be in normal face, since the <b> tag was closed with </b> immediately after the word "Hello". Other formatting tags are:

  • <u></u> (for underlining a phrase)

  • <i></i> (for italicizing, i.e. render a phrase with cursive face)

But how how can we change not only the face, but also the colour, the size and the font? For this, the <font> tag comes to our help (also deprecated in XHTML, use CSS instead, see Section 14.12, Section 28.3!). Let's take a concrete example and analyze it:

<font color="#FF0000" size="2">Hello World</font>

The code assigns some values to attributes of the font tag, that will apply to the "Hello World" text:

  • color="#FF0000": assigns the red colour to the text. Why red? Because only the first two hex numbers are set (to FF, which is the hexadecimal notation for 255), meaning that only the red component is active (there are three components, red, grren and blue, each one taking up two hex digits in the colur notation).

    Tip Colour wheels
     

    A useful tool in exploring the visible spectrum in HTML is the colour wheel. Just hover over the wheel with your mouse to view 4096 colors in their web safe, web smart and unsafe versions.

    You can also use the colour popups of the Tag-o-matic to show all 216 web-safe colours in a virtual colour card.

  • size = 2: assigns the size 2 to the characters of the "Hello World" string.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

 

Site Info v2.2.2

Last SeenLast Seen
Server TrafficServer Traffic
  • Total: 342,299,877
  • Today: 24,504
Server InfoServer Info
  • Nov 21, 2017
  • 07:46 am PST
 
 

Daily Inspiration