I have made a mistake in my code somewhere and have failed to close a tag or something like that. Thing is I just can't find that mistake. Does anyone know if there is a tool or something that can find the mistake for me?
If you are validating against an HTML doctype then this does permit certain elements to be left open (they will be closed automatically - but not necessarily where you expect?) - so you won't necessarily get a validation error. However, if you are validating against an XHTML doctype then all your elements must be closed in the source, so the validator will catch any unclosed elements in this instance.
Do you think there is a mistake because it doesn't look as you expect?
9:17 pm on Dec 13, 2011 (gmt 0)
The Firebug extension for Firefox allows you to inspect the DOM tree and temporarily change elements on the page and immediately see the effects.
9:21 pm on Dec 13, 2011 (gmt 0)
The formatting dies halfway down the page, but I use php includes and css and I am not sure where I have slipped up. will have a look at the firebug thing sounds good.
11:33 pm on Dec 13, 2011 (gmt 0)
By "formatting dies" do you mean that halfway through the page, it stops seeing your CSS? I'm impressed. I can do that easily for the whole page, but mid-page is harder.
The first place to look is the exact location where the formatting stops. And then start looking backward. That is, if your error happens in the middle of a series of <p class = "foobar"> then the problem may not become visible until the next time your html has to consult the CSS for something new.
Most obvious thing to look for: Are you using relative links to call your CSS? If so, does the page use the contents of more than one directory?
12:02 am on Dec 14, 2011 (gmt 0)
I have been working through the page and taking out includes and the stylesheet and closing some tags just to test. The page does use the contents of more than one directory but if I take out all the includes I still have the problem.
If I take out the stylesheet I don't have the problem though what I could have done to create this I am not sure as I never really change the stylesheet much.
What seems to be happening is that the stylesheet is ignored after a certain point, as if I stick some more stuff in the bottom that is ignored.
Having said that it is only text formatting that is ignored and not layout formatting.
12:09 am on Dec 14, 2011 (gmt 0)
Firebug lets you see which bit of the CSS applies to each HTML element.
By inspection you should be able to find the break.
12:37 am on Dec 14, 2011 (gmt 0)
Yes thanks, been playing with firebug, yet to find the bug
1:07 am on Dec 14, 2011 (gmt 0)
Segment the page into multiple TEXT files leaving the ending /body and /html tags in place. Work through the first one fixing the validation issue. Then add them back one at a time and repeat. After 20+ years doing HTML I end up doing this once a year or so. It creates a real 'face-palm moment' when you find it too!
There are a number of online HTML validators (<--- good search term). Sometimes these validator error reports are decidedly UN helpful. Comparison validation checks may find the one little thing that causes tens of errors to be reported.
Oh....by the way....welcome to WebmasterWorld justint!
4:31 am on Dec 14, 2011 (gmt 0)
Oh wait, wait. You said the formatting dies.
Does your CSS list styles in the order they are used? (It shouldn't, for other reasons, but never mind that now.) If so, the problem may not be in your HTML at all. It may be in your CSS, most likely exactly what you said in your first post: "failed to close a tag". If the CSS contains an error such as an unclosed bracket, the rest of the CSS will be ignored but everything before the error will be read normally.
4:42 am on Dec 14, 2011 (gmt 0)
W3C also has a CSS validator [jigsaw.w3.org] that might be a help.
9:50 am on Dec 14, 2011 (gmt 0)
I tried the CSS validator and it did sort one error which was a missing ; but still the main problem is there.
5:08 pm on Dec 14, 2011 (gmt 0)
You said includes. Is this PHP? If so, you can try viewing the source of the code , copy and paste it into a test file, or copy and use the "Validate by direct input" tab at the Validator.
You might want to do that anyway. Start with the most basic framework, then add chunks until the errors appear. Correct them as you go, and keep adding them until they are all gone.
5:03 pm on Dec 18, 2011 (gmt 0)
I think I will start again from the ground up, the website needs an overhaul anyway! :)