Search code examples
javascriptxhtmlvalidationmarquee

how to use marquee tag in xhtml


i'm using

<script type="text/javascript" >
    document.write("<marquee scrollamount='5' onMouseOver='this.stop()' onMouseOut='this.start()'><img alt='ibm' src='images/ibm.png' width='100px' height='100%' /><img alt='tcs' src='images/tcs.jpg' width='100px' height='100%' /><img alt='hp' src='images/hp.png' width='100px' height='100%' /><img alt='hcl' src='images/hcl.jpg' width='100px' height='100%' /><img alt='cts' src='images/cts.jpg' width='100px' height='100%' /><img alt='accenture' src='images/Accenture.png' width='100px' height='100%' /></marquee>");
    </script>

for marquee picture in my website, but when i'm checking my webpage into W3 Validator , then i'm getting error on the above code.

  • element "marquee" undefined
  • there is no attribute "onMouseOver"
  • there is no attribute "scrollamount"
  • there is no attribute "onMouseOut"

Need help to solve the above problem !!


Solution

  • The problems are explained in your question.

    • marquee is an old Microsoft thing and it should not be used.
    • onMouseOver is also not a defined attribute. You could use onmouseover, but rather, use unobtrusive event handlers.
    • The other issues can be explained by the above.

    Some bonus tips...

    • There are few reasons why you'd use document.write() or the marquee element in this day and age. Both can be achieved using more elegant and powerful means in JavaScript.
    • img elements width and height attributes should never include px.
    • If you're using a HTML5 doctype, the type attribute is no longer required on script elements if the script type is text/javascript.