Technology Software

Proper Formatting for HTML

    Beginning an HTML Document

    • All HTML files should begin with a doctype, which since HTML5 has become very simple:

      <!DOCTYPE html>

      The above doctype is for HTML5 but works with older HTML specifications as well. You must place this at the very first line of an HTML document. After this declaration, an HTML file needs opening and closing HTML tags: "<html>" and "</html>." Everything but the doctype will go between these tags.

    The Head and Body

    • Two parts make up an HTML document: the head and the body. The head goes between "<head>" tags, which you must place directly after the opening "<html>" tag. This portion of the document contains information about the Web page that does not appear on the browser screen, such as keywords or links to embedded files. Whatever you need to appear in the browser screen, such as text, forms and tables, goes between "<body>" tags that must come right after the closing "</head>" tag.

    HTML Tag Formatting

    • Write HTML tags in all lowercase letters between right and left angle brackets, like this:

      <strong>

      Most tags come in pairs of opening and closing tags that wrap around text you need to mark-up. The proper use of the tag above is as follows:

      <strong>This is strong text, which most browsers make bold.</strong>

      Some tags do not come in a pair, such as horizontal rules, line breaks, images and link tags (not related to hyperlinks, which use anchor tags instead). In XHTML, you must make the tag self-closing like so:

      <br />

    Tag Attributes

    • Attributes add extra information and formatting to HTML tags. Since the popularization of Cascading Style Sheets (CSS) around 2002, use of tag attributes for formatting is no longer considered a good practice. The generally accepted format for attributes uses double quotation marks around the attribute values, but you can get away with single quotes or even none. Here is an example:

      <img src="mypic.png" alt="My Picture" />

      The above code places an image in the HTML document and uses two attributes. The first -- "src" -- stands for "source" and tells the browser which image to load. XHTML requires use of "alt" for alternative text when the image fails to load.

    Nesting Tags

    • Nested tags refers to tags inside of tags, like the following example:

      <li><a href="/links/?u=link.html">Link</a></li>

      The above code creates an item in a list that contains a link. This is useful for building menus. When nesting tags, you should not nest like this:

      <strong><em>This is bold, italic text.</strong></em>

      Always close the last tag you opened. This keeps you from inadvertently creating strange, unwanted effects in your Web pages.

SHARE
RELATED POSTS on "Technology"
How Do I Print Business Cards With Microsoft Publisher?
How Do I Print Business Cards With Microsoft Publisher?
How to Reduce the Size of Photos Using Adobe Photoshop Elements 3.0
How to Reduce the Size of Photos Using Adobe Photoshop Elements 3.0
Features and Benefits of Project Portfolio Management
Features and Benefits of Project Portfolio Management
Fix Registry - Fix Registry Errors Easily
Fix Registry - Fix Registry Errors Easily
Business Intelligence Solutions and Services
Business Intelligence Solutions and Services
AutoCAD Architecture
AutoCAD Architecture
Best Social Networking Apps
Best Social Networking Apps
IKE
IKE
Help Desk Software by help-desk-software
Help Desk Software by help-desk-software
What's Better - Building a BPM Solution Or Buying One?
What's Better - Building a BPM Solution Or Buying One?
How to Make Music Fade out in Moviemaker
How to Make Music Fade out in Moviemaker
How to Shrink a DVD With Nero Instructions
How to Shrink a DVD With Nero Instructions
Live Chat Software: Four Tips To Help You Get the Most Out of Your Software
Live Chat Software: Four Tips To Help You Get the Most Out of Your Software
How to Stop Rootkits
How to Stop Rootkits
3 First-Rate Foundations for Making Movies
3 First-Rate Foundations for Making Movies
How to Build Game Downloads
How to Build Game Downloads
The Linux Modem How-To
The Linux Modem How-To
Text-Terminals on Linux - 11.6 Terminal Server Connection
Text-Terminals on Linux - 11.6 Terminal Server Connection
The Linux Loadable Kernel Module How-To
The Linux Loadable Kernel Module How-To
How to Create Photo Albums With CSS
How to Create Photo Albums With CSS

Leave Your Reply

*