Web Design Stuff
HTML Tutorials    CSS Tutorials    Web Hosting   Resources
Create a Web Page 101
Making Web Pages Intro What is a Web Page? Why Make a Web Page? The History of HTML Learn HTML or XHTML?
Basic HTML
Basic HTML Tutorials Basic HTML Necessities How to Make a Web Page How to Edit a Web Page The Basics of HTML Tags Basic HTML Page Structure HTML Attributes
HTML Font Codes
HTML Font Codes Intro HTML Font Color Codes HTML Font Size Codes HTML Font Style Codes HTML Bold/Italic Codes Combining Font Codes
Formatting Text
Formatting Text Intro Making Paragraphs Miscellaneous Formatting Headings & Subheadings Creating Hyperlinks
Using Graphics
Using Graphics on the Web Add Graphics to Your Pages Graphics and Accessibility How to Align Graphics Page Color & Background Graphics as Hyperlinks Horizontal Rules
Creating Tables
HTML Tables Tutorials HTML Table Fundamentals Background & Border Color Table Frames & Rules Table Width and Alignment Cells 1 -Space & Alignment Cells 2 -Row Column Span Cells 3 -Width & Height
Making Lists
HTML Lists Tutorials Bulleted Lists Numbered Lists Definition Lists
HTML Frames
HTML Frames Tutorials Using Frames for Layout Advanced Frame Layouts Putting Hyperlinks in Frames Frame Border Width Color, Margin and Control Problems with Frames SmartFrames: A Solution SSI: An Alternative to Frames
Web Page Forms
Making Feedback Forms A Simple Feedback Form Installing NMS FormMail Debugging Your Setup My Web Host is Out to Lunch User Input Components Text Fields Checkboxes & Radio Buttons Dropdown Menus Push Buttons Layout and Presentation
Basic CSS
Basic CSS Tutorials What is CSS? Why You Should Use CSS How to Use CSS Inline Styles Embedded Style Sheets External Style Sheets Class Selectors ID Selectors Combining Selectors
CSS Properties
CSS Properties Intro Font Styles Width, Height & Spacing Borders Backgrounds Position Float & Alignment Hyperlinks
All About Web Hosting
Hosting Your Own Website What is a Web Host? Your Website's Home Page Building a Website Offline About Free Web Hosting Best Free Web Hosting Commercial Web Hosting How to Get a Domain Name Ecommerce Web Hosting Web Hosting Terminology
Free Web Design Tools
Best Free Website Tools Best Free Text Editors Best Free Graphics Editors Free Website Analysis Tools
Setting Up HTML Kit
HTML Kit Introduction How to install HTML Kit Screenshot Breakdown Basic Configuration Overall Appearance Shortcuts and Startup Editing Window Customizing Toolbars Using the Favorites Tab Making a New Actions Bar Odds and Ends
Free Templates
Free Website Templates Two Column Fixed Width Three Column Liquid Layout Miscellaneous Templates Dynamic Menu Effects Two Column Experimental Terms of Use About These Templates
Website Templates Help
Getting Started Template Zip File Download How to Edit Your Template What to Edit in the HTML How to Add Your Logo Making a Website
Web Design Tips
Web Design Basics Tables vs. Tableless Using Tables for Layout Example Table Layouts World's Crappiest Web Page
Twitter Backgrounds
Twitter Backgrounds Intro Cool Twitter Backgrounds Cool Twitter Backgrounds 2 Plain Twitter Backgrounds Dark Twitter Backgrounds Best Twitter Backgrounds Cute Twitter Backgrounds Music Twitter Backgrounds Music Twitter Backgrounds 2 Twitter Backgrounds 101 TERMS OF USE
All About Web Browsers
What is a Web Browser? Mozilla Firefox Internet Explorer Opera How to Set Up Firefox Top 5 Firefox Extensions
 
Contact
Post Some Feedback Send Me An Email Iron Spider Blog About Iron Spider... Site Conventions
 
 
 

 

Combining HTML Font Codes

 
<b><i>bold and italics text</i></b>
Here's how to combine HTML font codes on your web page. We'll start off with a rundown on...


Inline Elements


The font element and all of the font style and special elements are known as inline elements. Unlike block level elements, the end tag of an inline element does not force a line break in the visible text.

Generally, inline elements may appear consecutively or may be combined so that one inline element contains one or more other inline elements. When inline elements appear consecutively, the first element terminates with its end tag before the second element begins with its start tag. This is best visualized by thinking of each element's start tag, content (visible text) and end tag all working together as one complete unit.

Nesting and Overlapping Tags


In Examples 1A and 1B, we'll break from conventions used on this website by color coding the visible text for demonstrational purposes:

Example 1A - Elements as Complete and Separate Units - RIGHT

<b>
Bold text
</b>
<i>
Italics text
</i>


Example 1B - Elements with Overlapped Tags - WRONG

<b>
Bold text
<i>
</b>THIS TAG IS OVERLAPPING.
Italics text
</i>


In Example 1B, the first element's end tag </b> 'overlaps' into the second element. In HTML coding, this is 'bad grammar' and should be avoided at all costs.

When two inline elements are used to produce a combined effect on the same text, the first element's start and end tags appear at the beginning and at the end of the combined set respectively while the second element's start and end tags are 'nested' within the first. This may be illustrated as follows:

Example 2A - Nested Tags - RIGHT

<b>
<i>
Bold and italics text
</i>

</b>



In Example 2A (above), the <i>...</i> tags are nested inside the <b>...</b> tags. The elements' tags must never be overlapped. To illustrate below:

Example 2B - Overlapped Tags - WRONG

<b>
<i>
Bold and italics text
</b>
</i>THIS TAG IS OVERLAPPING.


When combining inline elements (which are also known as text level elements), it doesn't matter which pairs of element tags are nested within others just as long as they are nested. Hence the following two examples are correct and produce identical results:

Example 3A

<font face="times new roman">
<i>
Times New Roman typeface rendered in Italics.
</i>
</font>


Example 3B

<i>
<font face="times new roman">
Times New Roman typeface rendered in Italics.
</font>
</i>



The following is a more complex example of correctly combining inline elements to apply to the same text as well as using inline elements consecutively. It also illustrates how text inherits formatting from the preceding text when one inline element is contained within another. In Example 4A, the elements' tags are color coded to illustrate the association between start and end tags and the code is expanded and stacked vertically for clarity:

Example 4A

<font face="Arial" size="3">

Arial font at size 3.

<b>

This text inherits all the formatting from the preceding text but is now displayed in bold. Hence it is Arial, size 3, bold.

<i>

This text likewise inherits all the formatting from the preceding text and adds on italics. (Arial, size 3, bold, italics.)

</i>

Italics has now ended but all other formatting continues. (Arial, size 3, bold.)

<font face="Times New Roman">

Now the font face changes to Times New Roman but continues as bold and size 3.

</font>

Now the Times New Roman font face has ended so the text returns to the Arial, size 3, bold.

</b>

Now the bold text style has ended and the text returns to its original Arial font at size 3.

</font>


(Note that web browsers will ignore all extra white space and line breaks created in the source code. See Making Paragraphs for more information.)

Click here to see the result of Example 4A on a web page...


Example 4B removes all the visible text and just displays the HTML coding:

Example 4B

<font face="Arial" size="3">
<b>
<i>
</i>
<font face="times new roman">
</font>
</b>
</font>



Note that there are no overlapping tags because:

  • The <b>...</b> tags are nested within the <font face="Arial" size="3">...</font> tags.
  • The <i>...<i> tags are nested within the <b>...</b> tags.
  • The <font face="times new roman">...</font> tags are also nested within the <b>...</b> tags.
  • The <i>...<i> tags terminate before the <font face="times new roman">...</font> tags begin.

This rule of making sure that there is no overlapping of tags applies not only to inline elements but to all HTML elements. If you review the basic HTML web page structure, you will see the no-overlapping rule clearly in action:

  • The <head>...</head> tags terminate before the <body>...</body> tags begin and thus they run consecutively without overlapping.
  • The <title>...</title> tags are nested inside the <head>...</head> tags.
  • Likewise both the <head>...</head> tags and the <body>...</body> tags are nested inside the <html>...</html> tags.
When you construct source code free of any overlapping tags, you are writing good HTML and your web pages will be far more likely to display as you intended.


Now that you are familiar with the concept of nesting HTML tags, let's move on and learn how to set your text into paragraphs using larger formatting structures called block elements...


See also:
  • What is Web Hosting?
  • How to Make a Web Page




Best Free Stuff
for webmasters

Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates

See also:

Best Free Web Hosting

 

If you need a .COM web address, you can get one quick and easy at...

www.GoDaddy.com
<~ BACK TOP NEXT ~>
 
HTML Tutorials |  CSS Tutorials |  Web Hosting |  Domain Names |  Web Design Resources
Iron Spider © Copyright 2004-2011 Robert Darrell