Not signed in (Sign In)

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  
    I have recently installed a new version of Firefox (3.7a1pre) and noticed that JavaScript doesn't work (I can't upvote an answer, can't star a question etc.).
    Of course, this version of Firefox is not stable and the problem might lie within Firefox itself (in which case I should probably submit a bug report to Mozilla),
    however, when checking some MathOverflow pages for HTML correctness I discovered that they are full of errors, see for example
    http://validator.w3.org/check?uri=http://mathoverflow.net/
    Many of these errors seem to involve JavaScript markup (e.g., see Line 1761, Column 168)
    and perhaps the incorrect markup is the source of the problem.
    Can we fix this?
    • CommentAuthorHarry Gindi
    • CommentTimeDec 29th 2009 edited
     
    Stop using weeklies. No page that I visit validates, and I do just fine.
  2.  
    MathOverflow is the only site that has problems with JavaScript in this version of Firefox.
    All other sites work perfectly.
    Also I do not think it is a very good idea to rely on one particular way of handling errors.
    After examining the home page more closely I see at least two problems:
    1) The script element does not have a type attribute.
    2) There are document.write commands with unescaped script tags inside, which is very very bad.
  3.  
    Take it up with stackoverflow.
  4.  
    This problem has nothing to do with StackOverflow.
    StackOverflow does not have any HTML errors on its front page (actually, it does have 3 of them, but they all are contained in a single element, which is a job advertisement and will probably be removed soon).

    As far as I can see, most errors on MathOverflow's front page
    come from the jsMath code, which is not present at StackOverflow,
    and Meta MathOverflow seems to be the right place for it.
  5.  

    I think the problems are from scripts that I'm putting in. I'll have a look at it.

    It seems stupid to me that opening tags within <script> tags don't get interpreted by the validator (they shouldn't), but that closing tags do. This means that if you write something like document.write("&lt;p>Here's a paragraph&lt;/p>' (pretend those "<'s are <'s) it complains. Is there actually a reason for this?

  6.  
    Thanks! As for the interpretation of script tags, I think you are not allowed to have a script element inside of another script element in the first place.
    I do not know why the validator handles it this way.
  7.  

    I don't ever have a script element inside of another script element. I have commands that write script elements inside of a script element, which is perfectly fine.

  8.  

    Now the validator doesn't complain about the front page. It still complains about the other pages, but it looks like they're silly complaints, like "ampersands that you're hreffing to should be encoded". I don't think I've ever seen anybody encode their ampersands in a URL. In particular, Fog Creek doesn't do it when they include the style sheet, and I don't control that bit.

  9.  

    Works perfectly for me.

    Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.3a1pre) Gecko/20091229 Minefield/3.7a1pre

    Is there actually a reason for this?

    Scripts should be CDATA in XHTML. Update: the MathOverflow pages validate against HTML 4.01, which has a different parsing rule, see second answer in the link.

  10.  

    @Ilya: but the home page isn't XHTML.

  11.  

    Indeed, as my update tried to express, home page advertises itself as HTML 4.01, for which the spec says

    the data begins immediately after the element start tag and ends at the first ETAGO ("</") delimiter followed by a name start character ([a-zA-Z]); note that this may not be the element's end tag. Authors should therefore escape "</" within the content.

  12.  
    @Anton: One problem that remains is that a few script elements do not have a mandatory type attribute.

    Also it is a good idea to encode ampersands in URLs. HTML has an enormous amount of character entities,
    many of them have names consisting of 2 or 3 characters. An accidental match will result in a dead link.

    Perhaps we should also submit a bug report to Fog Creek about this.
  13.  
    Apostrophes too. For example, http://math.boisestate.edu/~holmes/holmes/A%20Mathematician's%20Apology.pdf does not work, and I had to find the URL code for it.
  14.  

    Ok, I'm learning some things about html. For example, tables and lists cannot be in P tags, and the insides of blockquotes must be in P tags.

    • There are lots of errros that I have no control over, like the fact that ampersands are not escaped in the src property of the up/downvote arrows
    • Sometimes I don't know what the validator is talking about. For example, when I validate mathoverflow.net/questions/123, it complains about a <script> tag without a type attribute, but when I view the source for the same page, I can't find said script tag.
    • There are other times I don't know what it's talking about, like when it suggests I do what I did. The remaining error when it validates the homepage is

        Line 1709, Column 210: Attribute "TARGET" is not a valid attribute. Did you mean "target"?
       …/what-html-tags-are-allowed" target="_blank">basic HTML</a> and <a href="http
      
    • When validating the FAQ, it complains about my <h3> tags. What does it want me to do? I want those things to be H3s.

  15.  
    I think <h3> is deprecated, aren't you supposed to use css for that stuff now?
  16.  

    But <h3> appears in lots of places. For example, all the question titles on the home page are inside <h3> tags.

  17.  
    Don't take my word for it, I was just under the impression that specific tags like all of the old header tags were deprecated a while ago.
  18.  

    It's the combination of the <dt> tags and the <h3> tags. <h3>s, being headers, should occur outside the normal flow of text. <dt>s, being list elements, are within the normal flow of text.

    Basically, both are trying to do the same job and so there's no point in having both. Why do you have the list elements? The headers are a sort of list anyway so there doesn't seem to be any reason to have them both.

    Headers aren't depreciated, though I've heard that there's a proposal to make them nest automatically rather than having to specify the type each time. You just gotta use 'em right.

    All but two of your errors on the FAQ are of this type. Either ditch the list (and make sure that the <a> tag is inside the <h3> (What about open problems?)) or put the "headers" inside a span and use CSS to control the formatting.

    The homepage is invalid because the 'target' attribute is not allowed in HTML4.01 Strict. You're allowed it in Transitional, though. So either you can go to Transitional or you can simply remove the 'target' attribute. Does the 'target' do anything that you absolutely must have? It may be possible to replace its behaviour with a modicum of javascript.

    When validating the questions, you need to be careful what you are comparing with! The javascript on a page changes what is there depending on who is logged on. I just tried looking at the source and couldn't find what it was talking about, but then I noticed that in the source was the line:

    <input type="hidden" id="123-is-owned-by-current-user" value="true">
    

    It's lucky that you chose one of my questions to validate! That line obviously wouldn't be there if anyone else looked at that question, so something is altering the contents depending on who's looking at the page.

    That gave me the clue. When I do

    ~% wget http://mathoverflow.net/questions/123
    

    and look at the resulting download then sure enough, on line 119 it says

    <script>
    var scores = document.getElementsByClassName("reputation-score");
    if (scores.length == 0 || parseInt(scores[0].innerHTML.replace(",", "")) < 15) {
      document.getElementById("banner-top").style.display = "none";
    }
    </script>
    

    That 'script' should have a type.

    The lesson is to not use the 'view source' facility of your web browser to see the source because that may well not be what's getting validated. Of course, that does mean that to truly validate your pages then you ought to send each possibility to the validator. The way to do that is to take copies of the HTML ("Save as" from your web browser) under the different circumstances and send them to the validator. Then you know that what the validator is validating is exactly what you think that it is validating.

    By the way, well done for trying to get your pages to validate. It's very important to do.

  19.  
    Does the nLab validate?
  20.  

    Somehow I missed the answer by Andrew Stacey, who says the same things.

    <h3> tags. What does it want me to do? I want those things to be H3s.

    Those are block-level elements, you can't put them inside things like paragraph or list. Indeed, you shouldn't use definition list for sections. Instead, just write your text with

    <DIV class="q-and-a">
      <H3> header </H3>
      <P> body </P>
      <P> another paragraph </P>
      <H3> header </H3>
      <P> body </P>
      <P> another paragraph </P>
    </DIV>
    

    and control the properties of H3 and P in the CSS. I guess if you just change tags DT -> H3 DD -> P you'll have the reasonable CSS; you might want to add P { margin-left: 1in; } or whatever you wanted from DD.

    (You could also leave this a definition list and remove the sections; but you'll be breaking things for devices that would try to automatically create contents from headers. Again, what you have here is normal sections, so it should be called that).

    It might make sense to take a look into official W3C (which is inside Bill Gates-sponsored building at MIT :) HTML 4.01 specification; it's quite fascinating reading. For example, this is said about P:

    The P element represents a paragraph. It cannot contain block-level elements (including P itself).


    I think <h3> is deprecated, aren't you supposed to use css for that stuff now?

    Interesting misconception. No, noone would suggest that — HTML describes the content, CSS describes the formatting. Theoretically you could use DIVs with different classes instead of other HTML tags, but this will break the HTML model, and it's actively not recommended. You could use HTML5 SECTION tag (this is the one that automatically nests, as Andrew says)... but alas, for now it's actually recommended to use it together with H# (every browser knows HTML4, few know HTML5).

  21.