Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

60 users online



[Article] XHTML/CSS Reference

[Article] XHTML/CSS Reference

Currently viewing this thread: 1 (0 members and 1 guests)


James

James

Development Forum Leader
Status: Offline!

[Article] XHTML/CSS Reference

A standard reference for commonly used code in stuff.

HTML Doctypes

Code:

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

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

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

XHTML Doctypes

Code:

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

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

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

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

Basic template for valid XHTML document - stripped down.

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML 1.1</title>
<meta http-equiv="Content-Type" content="text/xhtml+xml; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="en-us" />
</head>
<body>
<div>

</div>
</body>
</html>

Note that the Content-Type meta tag is irrelevant, but necessary to validate using the validator. The <div>s can be any block-level element AFAIK but you cannot just type text in between the <body> tags.

CSS Hacks
Tantek Box Model Hack

Code:

#content {
/* IE 5.x width */
width: <content width + paddings + borders>;
voice-family: "\"}\"";
voice-family:inherit;
/* IE 6, and all other browser width */
width: <content width>;
}


Other Less Messier BMH

Code:

#content {
width: <content width + paddings + borders>;
width/* */:/**/<content width>;
width: /**/<content width>;

/* other declarations may appear anywhere in this rule */
}


Source: Alternate Box Model Hacks

Barebones Layout Example

Basic CSS-style fixed(not fluid) layout with a header, small right column, large left (content) column, and footer (floats)

index.html

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML 1.1</title>
<meta http-equiv="Content-Type" content="text/xhtml+xml; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="en-us" />
<style type="text/css" media="screen">@import "screen.css";</style>
<style type="text/css" media="projection">@import "projection.css";</style>
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
</head>
<body>
<div id="container">
<div id="header">
<a href="#"><span>XHTML 1.1</span></a>
</div>
<div id="left">NICe NaVIGATION</div>
<div id="right">SupeRb ConTENT</div>
<div id="footer">© OMGHAX Ltd. 2005</div>
</div>
</body>
</html>

screen.css

Code:

@import "all.css"; /* just some basic formatting, no layout stuff */

body {
margin: 0;
padding: 25px;
}

#container {
width: 600px;
margin: 0 auto;
background: #fff url(hax.jpg) repeat-y;
/* background gives appearance of maximum height
of #left and #right */
}

#header {
width: 600px;
height: 100px;
background: #efefef url(bg.jpg) no-repeat top left;
}

#header a {
display: block;
width: 600px;
height: 100px;
}

#header a span {
display: none;
}

#left {
float: left;
width: 200px; /* IE 5.x width */
padding: 10px;
background: #fff;
/* Tantek Box Model Hack */
voice-family: "\"}\"";
voice-family:inherit;
width: 180px; /* IE 6 and other browsers width */
}

#right {
float: left;
width: 400px;
padding: 10px;
background: #ddd;
/* Tantek Box Model Hack */
voice-family: "\"}\"";
voice-family:inherit;
width: 380px;
}

#footer {
clear: both;
background: #eee;
width: 600px;
padding: 5px;
/* Tantek Box Model Hack */
voice-family: "\"}\"";
voice-family:inherit;
width: 590px;
}

all.css

Code:

body {
font: .9em/1.3em Arial, Helvetica, sans-serif;
color: #666;
}

#footer {
font-size: .7em;
}

/* other nice stuff, etc */

projection.css

Code:

@import "screen.css";

* {
font: 1.2em/1.7em bold Arial, Helvetica, sans-serif}
} /* zomg easy to read from afar */

print.css

Code:

* {
background: #fff;
font: 12pt/17pt Georgia, "Times New Roman", Times, serif;
}

#right {
text-align: justify;
}

#footer {
font-size: 9pt;
}

#left {
display: none;
}

Suggestions welcome.

___________________

irc.efnet.net #neverside
Neverside merchandise!

Last edited by James, May 26th, 2005 06:29 PM (Edited 2 times)

Locke

Locke

"Refocusing" My Time
Status: Offline!

An excellent and very well written article, great job James.

___________________

The Audoptic Weblog. It's where the magic happens.

Gil

Gil

Semantics Whore
Status: Offline!

Great reference (article isn't really the word). This is the kind of thing I'd bookmark or even print out and hang next to my screen. I think there should be more references like this, with examples and grunt code...

Good job Jamezor!

kiswa

kiswa

Yeah, kiswa.
Status: Offline!

Definitely a very useful reference. Good work James!

We'll make sure CodeBase has some articles, won't we? Wink

___________________

www.kiswa.com
My attempt at articles for Neverside CodeBase: Part 1 Part 2 Part 3
(. )v( ·) <- The Webstandards Owl

Gil

Gil

Semantics Whore
Status: Offline!

CodeBase should be huge at launch, that'd be great, no? Grin

army

army

Neverside Peacekeeping Forces
Status: Offline!

i suggest for those who wants to write article to have "[ artice ]" at the front of the title as a prefix so we will know what topic has been discussed ansd what topic has not

___________________

"The only thing i hate about Sunday is that because tomorrow is Monday"
army

Gil

Gil

Semantics Whore
Status: Offline!

Well, Shawn bundles all the article threads in that sticky at the top, so you'd better check there first. Oh, and it's not a disaster to write two on the same subject, it's always great to see a point from two different angles...

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.009 seconds.