My HTML tags gets tampered with

Go To


I have an Umbraco 5 MVC3 project where i discovered that there where white spaces here and there. When investigating i discovered that my HTML looked really bad when "viewing generated source" in firefox web developer tool. For example it removes my doctype declaration and moves my meta-tags and stuff out of the head. Simplified code:

<!doctype html>
<html class="no-js" lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="@Url.Content("~/Content/Styles/style.css")"/>
<body id="" class="default">
    <div id="wrapper">
        <header id="banner" class="body">
            <a class="ir logo" href="/"><h1>Christian </h1></a>
            <ul class="share">
                <li id="facebook"><a class="ir" href="">Facebook</a></li>
                <li id="twitter"><a class="ir" href="">Twitter</a></li>
        <section id="content" class="body">
    <script src="@Url.Content("~/Scripts/plugins.js")"></script>
    <script src="@Url.Content("~/Scripts/script.js")"></script>

And the output begins like this

<html class="no-js" lang="en"><head></head><body id="" class="default">
2012-04-04 17:15
by Johan B


Alright, i solved it. Took me a while. After Marapet suggested not to use "generated source" i tried normal "view source" in a bunch of browsers and got different results in all of them. When i tried to validate my source i got some weird complaints:

Non-space characters found without seeing a doctype first. Expected <!DOCTYPE html>.

Element head is missing a required instance of child element title.

And my personal favourite

Cannot recover after last error. Any further errors will be ignored.

Looked like there was something up with the doctype. Opened up notepad and pasted in there to "wash" the code from metadata, the way i do sometimes when pasting stuff in to tinyMCE. The text got formatted weird even in notepad. The doctype declaration had a smaller font size then the rest of the html.

So i opened it in notepad++ too and there i got a bunch of questionmarks in front of the declaration. I removed them and copied it back in to Visual Studio, saved and now everything works.

I think the reason i got this problem was that i copied snippets directly from the HTML5 Boilerplate on github.

// Sherlock

2012-04-05 09:34
by Johan B


If you want to check on the HTML generated by your server, you should use View source (CTRL + U).

Generated source is more like a reconstruction of the HTML based on the DOM and includes for example nodes created on the client side with javascript, once the page is loaded.

2012-04-04 18:01
by marapet
Thanks man for clearing that up. This was a weird problem - Johan B 2012-04-05 09:12