html 5 marquee tag error in w3c validation

夙愿已清 提交于 2019-12-12 14:27:24

问题


I have some text in marquee tag.

<marquee direction="left" scrollamount="4">
 Test Test Test Test Test
</marquee>

I am using html 5 and css 3. When i check my html in w3c validator, it shows the following error.

 Element marquee not allowed as child of element div in this context. (Suppressing further errors from this subtree.)

        <marquee direction="left" scrollamount="4"> 

How to fix this?


回答1:


Marquee tag is not html5 (is not html at all, but Microsoft proprietary tag from 1995)

you can :

  • use javascript to animate your text
  • use css animation (not fully browser compatible)
  • use css3 marquee (not fully browser compatible)
  • use marquee and ignore W3C warning (marquee is full browser compatible, even in iOS safari!)
  • don't use marquee effect (it's ugly)

Be careful with W3C validator, it is not always know all W3C specifications !




回答2:


The marquee tag has been made obsolete in HTML5, but has returned in CSS3 (see http://www.w3.org/TR/css3-marquee/).




回答3:


Use CSS3 Marquee instead of it

html

<p class="marquee"><span>This is your sample text.</span></p>

css

/* Make it a marquee */
.marquee {
    width: 450px;
    margin: 0 auto;
    white-space: nowrap;
    overflow: hidden;
    box-sizing: border-box;
}

.marquee span {
    display: inline-block;
    padding-left: 100%;
    text-indent: 0;
    animation: marquee 15s linear infinite;
}

.marquee span:hover {
    animation-play-state: paused
}

/* Make it move */
@keyframes marquee {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(-100%, 0); }
}


来源:https://stackoverflow.com/questions/15128716/html-5-marquee-tag-error-in-w3c-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!