HTML Code Snippets

IE only HTML element

<!--[if IE ]>
   <body class="ie">
<![endif]-->
<!--[if !IE]>->
   <body>
<!--<![endif]-->

First part is if the browser is IE and the second part is if not IE, which is stated using !IE.

DOCTYPES

HTML 4.01 Strict

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

HTML 5

<!DOCTYPE html>

Empty Table Markup

<table>
	<thead>
		<tr>
			<th></th>
			<th></th>
			<th></th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
	</tbody>
</table>

Embedding Quicktime

Quicktime still requires the double-object method to get it done across all browsers. Not super pretty, but it does get the job done. If you want to change the size, look for the width=”200″ height=”16″ and change it to whatever size you want.

<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
       codebase="http://www.apple.com/qtactivex/qtplugin.cab"
       width="200" height="16">
 <param name="src" value="movie.mov" />
 <param name="autoplay" value="true" />
 <param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
 <param name="controller" value="true" />
 <!--[if !IE]> <-->
   <object data="movie.mov" width="200" height="16" type="video/quicktime">
     <param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
     <param name="controller" value="true" />
   </object>
 <!--> <![endif]-->
</object>

XHTML 1.0 STRICT Page Structure

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
       <title>Page Title</title>
       <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/>
</head>
<body>
Content you want displayed goes here.
</body>
</html>

Meta Refresh

This code snippet redirects to the provided URL in 5 seconds. Set to 0 for an immediate redirect.

<meta http-equiv="refresh" content="5;url=http://example.com/" />

Embedding Flash

Using the <embed> tag is not valid XHTML, therefore try using this, which is fully XHTML valid.

<object type="application/x-shockwave-flash"
	data="your-flash-file.swf"
	width="0" height="0">
	<param name="movie" value="your-flash-file.swf" />
	<param name="quality" value="high"/>
</object>