tags:

views:

96

answers:

2

What could affect the location of text outside of <div>...</div>? They are using the same CSS but text appears in 2 locations on 2 different pages.

Here are 2 sample pages:

Homepage link shows in the correct location: CodeList

Homepage link shows in the wrong location: Code Assessment

I copied and pasted all the top section html on CodeList to CodeAssessment and the text skewing remains. I turned on show Whitespace in Visual studio, but since what I believe to be the relevant text was copied and pasted, that didn't reveal anything.

I'm using the Gestured template from FreeCssTemplates. The location of those links is not related to their intended usage, I just copied and pasted the html out to somewhere I could easily link them for testing and assistance. So I know the form components may appear not to work, but this isn't their home. They work here locally on my IIS and inside cassini.

+3  A: 

Not sure what your question is, but my advice: make sure any HTML code validates before you try to fix design or rendering errors (or browser dependency bugs for that matter). In any case, never place any layout outside the boundaries of <body>...</body>. Fix it, and you'll be able to effectively use CSS on them.

In a meanwhile deleted answer, Peter Lacomb Jr spotted that backslashes where used where URI was required. Backslashes are illegal anywhere else then in Windows (and then only for file paths). For URIs, URLs etc: never use backslashes. They have no special meaning. Forward slashes, on the other hand, do have special meaning: as a path separator.

Looking further:
The offending page starts out with a comment. I don't know why you put it there, but this triggers backwards compatibility mode. Your code is XHTML. Let it start with an XML declaration. Also, fix the <script> body as Peter suggested, like so:

<script ...>
//<![CDATA[
     functionA(...) { blabla; }
     functionB(...) { blabla; }
     etc...
// ]]>
</script>

And no, it doesn't affect the javascript itself. It's just for making it easier to write < and &, which need to be escaped, but not inside XML CDATA sections. You should actually always do this when using XHTML.

To check whether the document is in backwards compatibility (quirks) mode type the following in the address bar of IE after you've loaded your page. You'll notice it is different for the two pages:

javascript:alert(document.compatMode);
Abel
@Abel well maybe the question is misleading, the entire section that should affect where the homepage link shows up is from `<body>` to `<div id=page>` but the two pages have homepage showing in a different part of the top graphic. I see the validation errors, but they weren't there when I pasted the text directly into the validator. besides one about my script containing < which is the less than sign. I'll keep checking on why the new errors are showing up now that I've pasted it to an internet site. but direct input validation on http://validator.w3.org/ didn't show me anything useful.
Maslow
Add //<![CDATA[ //]] blocks around the contents of your upper script blocks to see more useful stuff in the validator.
Peter LaComb Jr.
@Abel backslashes are fixed to forward slashes. issue continues, but now I can see it only happens in IE. Firefox doesn't have this text location problem
Maslow
It only happens in IE on 1 out of 4 pages I've made so far.
Maslow
I'm surprised that you didn't get errors when you pasted it in directly. There are some serious and some less errors in your first link: `disabled` should be `diabled="disabled"`, `checked=""` should be `checked="checked"` for XHTML. Important: you have an XML declaration half-way (it must be the first thing, even before whitespace, only), this may screw up some layout issues.
Abel
See my update. Quirks mode has a major impact on how a page is rendered. Make sure both have the same compat mode.
Abel
@Abel I think you are referring to issues on the CodeList.aspx page. That page is functioning fine on IE, I'll look at it nonetheless but the issue I'm having is with the Homepage link placement on the CodeAssesment.aspx page.
Maslow
@Abel the previous reply was before your update and the Quirks mode. I'm not sure how to implement Peter's CData, wouldn't that turn off the javascript? if so then I imagine I turn off the javascript just for html validation then turn it back on. checking into the quirks mode and your update now.
Maslow
@Maslow: see my update in the answer on the CDATA issue.
Abel
+1 the comment `<!--EnableViewStateMac="False" !-->` was causing the problem. what an odd problem thanks a ton. Love the javascript helper too. I'm going to add the `//<![CDATA[` but I'd rather learn how to put my scripts off into .js files or a clean way to put them in my .cs files.
Maslow
Note: the comment itself did not cause the problem, but the absence of `<?xml ...?>` as first statement. To be safe, just move your comment(s) to after the doctype declaration.
Abel
+1  A: 

I see that you're using .NET for your application. Are you using master pages for the layout of the site? I'm going to assume that you are.

The section on the CodeAssessment.aspx page which is marked:

<div id="Div1"></div>

probably shouldn't have been copied and pasted into that page at all. That section should have probably been left on the master page. You content areas are where you should have your application (the dropdowns, the radio buttons, etc).

Take a look at using Master Pages on asp.net and see how they break up a site and use master pages in conjunction with content pages.

All you really have to do is make sure that your master page is valid and then your content pages should work like expected.

Good luck, and hope this helps some.

Chris
There's no master page, although I imagine it would have been a good idea, the site isn't currently set up that way.
Maslow
It would save you the trouble of repeating certain tasks from page to page. And your current problem: the start of the page, would be dealt with by the masterpage. It would've prevented all this (probably). The little learning involved understanding masterpages is quickly earned back!
Abel
I would recommend starting over with a master page, creating a few user controls for things like the header, footer, main navigation and then start making content pages for the meat of the application. It will be worth it in the long run.
Chris