Firefox ignores option selected=“selected”

前端 未结 20 1658
你的背包
你的背包 2020-11-28 21:59

If you change a dropdown and refresh the page, Firefox seems to ignore the selected attribute.

20条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 22:38

    I'm using FF 25.0.1

    It ignore selected="" and selected="selected".

    But if I simply try selected the option is selected.

    Strange (non conformant) behaviour. I know selected is valid HTML5 and it's the shortest form, but I usually write code that also validates as wellformed XML, so that I can use any XML validation tool to check my results in a very strict way (and data exchange is very easy...)

    According to W3C, these variants should be valid on boolean attributes:

    HTML5:  boolAttr="" | boolAttr="boolAttr" | boolAttr
    XHTML5: boolAttr="" | boolAttr="boolAttr"
    

    I prefer the first one, as is it nearly as short as the last (not xml conformant) variant but should validate as both XHTML5 AND HTML5. So I hope, Mozilla will fix it!

提交回复
热议问题