Thank you for your help.
I used comment tags to hide the JavaScript from non-JavaScript-enabled browsers. I was taught in college that <!-- and closing with //--> was the appropriate syntax; while the script element delimits the script's code, <!-- --> actually hides it so that it doesn't display as page content. The // before the closing --> circumvents a possible "erroring out" of the script.
The same principle applies to the style element, though the // isn't needed when closing the comment.
As far as my code's unsemenatic-ness is concerned, you're probably right. I'm using the div element as a generic, non-descript block element. The id and class makes CSSing and scripting easier. I've never run across the label element before so it was new to me; Thanks for pointing it out!
I'm using points as the measurement for borders simply because it's a measurement I use often. Stroke's almost always measured in pt sizes in such applications as Illustrator, Flash, etc. It's just force of habit for me... but it's a measurement I understand, too.
I certainly wouldn't want to sacrafice brower compatability, though. "Know they audience," right? The page will be viewed on Konqueror, Mozilla, IE and Lynx. A sharp look that degrades nicely to text browsers is a must!
Below's my code at this point.
Code:
<style type="text/css">
<!--
* {
font-family: Arial, Sans, sans-serif;
font-size: 10pt;
}
form {
width: 40ex;
border: 1pt solid black;
text-align: right;
background: url("../img/background.gif");
background-position: bottom left;
background-repeat: repeat-x;
padding: 0.25ex 0.75ex;
}
#formheader {
text-align: left;
font-size: xx-small;
color: #900;
font-weight: bold;
}
label {
margin-right: 0.75ex;
}
input {
width: 29.75ex;
}
.button {
width: 49%;
}
textarea {
width: 39.5ex;
}
fieldset {
border: none;
margin: 0px;
padding: 0px;
}
#mesg label {
display: none;
}
#preview {
width: 40ex;
border: 1pt solid black;
padding: 0.25ex 0.75ex;
margin-top: 1em;
display: none;
}
#btns {
text-align: center;
}
-->
</style>
...
<script type="text/javascript">
<!--
function stripHTML(text) {
if (text) {
text = text.replace(/</g, "<");
text = text.replace(/>/g, ">");
return text;
}
else return null;
}
function formPreview()
{
text = document.getElementById('body').value;
text = stripHTML(text);
if (text) {
document.getElementById('preview').innerHTML = text.replace(/\r/g, "<br />;");
document.getElementById('preview').style.display = "block";
}
else document.getElementById('preview').style.display = "none";
return true;
}
//-->
</script>
...
<form action="post.php" method="post">
<div id="formHeader">Post New Thread</div>
<fieldset id="name">
<label>Name:</label>
<input type="text" name="name" />
</fieldset>
<fieldset id="mail">
<label>E-Mail:</label>
<input type="text" name="mail" />
</fieldset>
<fieldset id="subj">
<label>Subject:</label>
<input type="text" name="subj" />
</fieldset>
<fieldset id="mesg">
<label>Message:</label>
<textarea name="body" id="body" cols="34" rows="5"></textarea>
</fieldset>
<div id="btns">
<script type="text/javascript">
<!--
document.write("<input type='button' class='button' value='Preview' " +
"onclick='formPreview();' />");
//-->
</script>
<input type="submit" class="button" value="Post" />
</div>
</form>
<div id="preview"> </div>
-Tim