Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Sub - Page best practices

Explorer ,
Jan 19, 2009 Jan 19, 2009
My site has a main index.cfm template which loads "sub-pages" (say #content, #navbar, etc)

What if anything should I put in the header of the subpages??? Specifically, below is in my index.cfm (most put there by DW automatically) but for the pages which (are NOT designed to be seen independently of the .index) what should/need be used?

FWIW, heretofore I have put nothing save comments at the top of subpages BUT have recently been compelled to move SOME css into the subpages (rather than all in the index.cfm css link) and thus need to have at least a <head><style type="text/css"> . . . </style></head> area (plus I then have put in a body tag as well).

But I have noticed that when doing so some of the DW code highlighting does not work (i.e. divs won't stay blue, cfouputs won't stay red etc). even when they seem to my eye to be proper.

Thanks in advance for any and all comments,

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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
TOPICS
Getting started
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2009 Jan 19, 2009
If you sub pages get rendered in frames, they should have their own doctype, html, head, and body tags. Otherwise, they should not have any. They should be somewhere between the body tags of the main page.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 19, 2009 Jan 19, 2009
You can answer your own question. View the source of your resulting rendered page. How many times does <head>...</head> show up where it shouldn't be (namely, after the opening <html> tag and before the opening <body> tag). Any <head>...</head> tags that are inside the <body> tag are invalid HTML according to spec, and most definitely invalid XHTML, even Transitional XHTML. The (trimmed, necessary elements only, without attribute declarations) DTD you specify in your DOCTYPE declaration specifies:

<!ELEMENT html (head, body)>

<!ENTITY % head.misc "(script|style|meta|link|object|isindex)*">
<!ELEMENT head (%head.misc;,
((title, %head.misc;, (base, %head.misc;)?) |
(base, %head.misc;, (title, %head.misc;))))>

<!ELEMENT body %Flow;>
<!-- %Flow; mixes block and inline and is used for list items etc. -->
<!ENTITY % Flow "(#PCDATA | %block; | form | %inline; | %misc;)*">

<!ENTITY % block
"p | %heading; | div | %lists; | %blocktext; | isindex |fieldset | table">
<!ENTITY % heading "h1|h2|h3|h4|h5|h6">
<!ENTITY % lists "ul | ol | dl | menu | dir">
<!ENTITY % blocktext "pre | hr | blockquote | address | center | noframes">

<!ENTITY % inline "a | %special; | %fontstyle; | %phrase; | %inline.forms;">
<!ENTITY % special.extra
"object | applet | img | map | iframe">
<!ENTITY % special.basic
"br | span | bdo">
<!ENTITY % special
"%special.basic; | %special.extra;">
<!ENTITY % fontstyle.extra "big | small | font | basefont">
<!ENTITY % fontstyle.basic "tt | i | b | u
| s | strike ">
<!ENTITY % fontstyle "%fontstyle.basic; | %fontstyle.extra;">
<!ENTITY % phrase.extra "sub | sup">
<!ENTITY % phrase.basic "em | strong | dfn | code | q |
samp | kbd | var | cite | abbr | acronym">
<!ENTITY % phrase "%phrase.basic; | %phrase.extra;">
<!ENTITY % inline.forms "input | select | textarea | label | button">
<!-- these can occur at block or inline level -->
<!ENTITY % misc.inline "ins | del | script">
<!-- these can only occur at block level -->
<!ENTITY % misc "noscript | %misc.inline;">

Meaning a valid XHTML-transitional document consists of, at minimum:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
</body>
</html>

But nowhere inside the body tag can you have another head or body tag. So, short answer, you shouldn't HAVE a header (<head>...</head>) in your subpages (unless, as Dan says, they're being rendered in frames, in which case they have to be complete, valid pages on their own).
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2009 Jan 20, 2009
Thanks to you both. Follow up though, as I understand it the css page(s) are loaded and saved into browser cache. My single CSS link/page is however getting quite long.

What are your thoughts on breaking it up into separate pages (obviously with 2+ links in the index.cfm header) -- both for manageability and for specificity (i.e. I have six slightly differing #content Divs)?

I know I can devolve down to in-line CSS on each of the different divs (and think I am correct in saying that neither a link to an external CSS page and/or <style> definition on a sub page is possible) . . .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 20, 2009 Jan 20, 2009
quote:

Originally posted by: ProjectedSurplus
Thanks to you both. Follow up though, as I understand it the css page(s) are loaded and saved into browser cache. My single CSS link/page is however getting quite long.

What are your thoughts on breaking it up into separate pages (obviously with 2+ links in the index.cfm header) -- both for manageability and for specificity (i.e. I have six slightly differing #content Divs)?


Sounds like extra work with no accmplishment.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 20, 2009 Jan 20, 2009
> What are your thoughts on breaking it up into separate pages (obviously with 2+ links in the index.cfm header) -- both for manageability and for specificity (i.e. I have six slightly differing #content Divs)?

You can break it up, it won't hurt anything. Do it by category (like nav.css, header.css, body.css, common.css) or something else.

> btw, part of why I set out on this possible goose chase is that I had hoped to be able during editing to preview in the browser the subpages independently of the index.cfm (ie if I preview only the subpage then there is no css link and hence no formatting)

I don't code the same way as you, so I can't provide any recommendation here. I don't use a WYSIWYG editor like Dreamweaver.

>Presumably these (duplicate) body tags are similarly redundant/non-conforming so is there an easy alternative (code or site to read)?

<script language="Javascript/1.0">
document.SignInForm.password.focus();
</script>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2009 Jan 20, 2009
quote:

<script language="Javascript/1.0">
document.SignInForm.password.focus();
</script>


does not seem to work. Am I missing something (note I am putting the script on a "sub-page" insofar as depending on which of these subpages is shown the cursor will go to a different form element).

I googled ( http://www.webdeveloper.com/forum/showthread.php?t=8846) which refers to a
<body onload="placeCursor()"> in addition to the script:
<script type="text/javascript">

function placeCursor(){
document.formName.fieldName.focus();
}

</script>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 20, 2009 Jan 20, 2009
LATEST
That will work more reliably. Just need to ensure that you're not defining more than one placeCursor() function.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2009 Jan 20, 2009
btw, part of why I set out on this possible goose chase is that I had hoped to be able during editing to preview in the browser the subpages independently of the index.cfm (ie if I preview only the subpage then there is no css link and hence no formatting)

thoughts on whether I am just chasing my tail here :)?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2009 Jan 20, 2009
also, to put the cursor into the appropriate form onLoad I have <body> tags per:

<body onLoad="document.SignInForm.password.focus();">

Presumably these (duplicate) body tags are similarly redundant/non-conforming so is there an easy alternative (code or site to read)?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources