Basics of XHTML – Part #2
As we covered in the Basics of XHTML, we have basics rules that we need to follow in order to correctly write XHTML and get the results we want.
<start tag>content</end tag>
We already learned some very basics XHTML elements that are very useful such as adding images and links to web pages.
<img src="image.gif" width=125" height="125" alt="image" /> <a href="index.html">Home</a>
HTML Attributes
- HTML Elements can have Attributes
- Attributes provide more info about the element
- Attributes are always defined in the start tag
The general syntax for these attributes is as follows:
<start tag attribute="value">content</ending tag> <a href="http://www.atomicpages.net">AtomicPages</a>
Given our basics syntax rules for attributes, we can see that the actual attribute is not inside double quotes but is within the starting tag. The value, however, is inside of double quotes. Please see Using Good Practices when Writing XHTML for additional details and tips for writing proper XHTML.
Common Attributes
Here is a list of some very common attributes.
<start tag class="class_name">content</end tag> <start tag style="inline css">content</end tag> <start tag id="id_name">content</end tag>
You can refer to ID v. Class and Basics for CSS for more details.
HTML Formatting
Whether we’re aware of it or not, there are ways to use HTML elements instead of using inline, ID, or class attributes of CSS. Basically, for simple formatting purposes, strong, emphasized , underlined, Big, etc.. There are ways to achieve these results without using Style Sheets. You can actually do some pretty crazy things with some seemingly arbitrary HTML elements.
Text Formatting
| Tags | Description |
|---|---|
| <b> | Bold Text |
| <strong> | Strong Text |
| <i> | Italic Text |
| <em> | Emphasized Text |
| <u> | Underlined Text |
| <s> | Deprecated, strikethrough text. Use <del>. |
| <strike> | Deprecated, strikethrough text. Use <del>. |
| <del> | Deleted Text |
| <ins> | Inserted Text |
| <sub> | Subscript Text |
| <sup> | Superscript Text |
| <big> | Big Text |
| <small> | Small Text |
So what do all of these insane tags do? Well, let’s start form the top!
- Bold and Strong are basically the same thing.
- Italic and Emphasized basically do the same thing.
- Underlines Text without the use of styles.
StrikeandStrikethoughdo the same thing but are depreciated1Deleted Textis the preferred way of creating “strikethough” text.- Inserted Text is an alternative way of creating underlined text.
- Subscript is subscript text probably used for mathematical notations.
- Superscript is superscript text probably used for mathematical notations.
- Big is a way of creating big text without styles.
- Small is a way of creating small text without styles.
Computer Text
| Tags | Description |
|---|---|
| <code> | Computer Code Text |
| <pre> | Preformatted Text |
| <samp> | Sample Computer Code |
| <tt> | Teletype Text |
| <kbd> | Keyboard Text |
| <var> | Defines a Variable |
- Basically, Code, Pre, Teletype, Sample Computer Text, and Keyboard Text all do the same exact thing: turn text monotype. The only difference these different elements would make is if you want to apply individual styles to them and use them in different ways.
- Variables is the only fancy element that does not make the text monotype but actually emphasized. This too can be made into almost anything we’d want via styles.
Quotes, Citations, etc
| Tags | Description |
|---|---|
| <blockquote> | Long Quotations |
| <q> | Short Quotations |
| <cite> | Cites something |
| <address> | Address Element |
| <abbr> | Abbreviation Element |
| <dfn> | Definition Term |
| <bdo> | Text Direction |
-
Generally you’ll see blockquote on forums or blogs somewhere, you’ll click “quote” and then a new window will pop up and you’ll see blockquote in HTML of BB Code form (usually). As you can see, using this blockquote element, our text is the same, however, the background is different to signify this long quote.
The “q” element is a short quote.
Notice how the “q” element is simply surrounded by double quotes to signify it’s existence as a short quote.- Cited text it different to let users know that whatever you are referring to is a cited source. You may want to utilize the “sub” and/or “sup” elements when using the “cite” element so you can create footnotes at the bottom of the web page.
-
The address element if for placing an address in
. The text is intentionally different for the specific use of an address. You can alter the styles of this element via CSS as usual.
- A definition term is more like a type of list. We will be covering this later on.
- This “bdo” element is basically useless unless you want to confuse your visitors.. This text will read from left to right. This text well read from right to left.(This text will read from right to left — it’s backwards!)
1. Depreciated — These are outdated HTML elements that have been replaced by more conventional, functional, and flexible alternatives. Though some browsers may support these elements, their continued support cannot be assumed; eventually these tags will become obsolete and browsers will not support their functionality.
A List of Depreciated Elements and their Alternatives
| Tags | Description | Replacement |
|---|---|---|
| <applet> | Inserts Applet | <object> |
| <basefont /> | Sets defaul font color and size | font style sheets |
| <center> | Centered Text | text-align:center; |
| <dir> | Directory List | <ul> |
| <font> | Font, color, and size of text | font style sheets |
| <isindex> | Adds search field | <form> |
| <menu> | Menu List | <ul> |
| <s> | Strike through text | <del> or style sheets |
| <strike> | Strike through text | <del> or style sheets |
| <u> | Underlined text | text-decoration:unerline; |
| <xmp> | Preformatted Text | <pre> |



