Introduction
This article explains how to use a marquee with HTML and JavaScript. A marquee is used to move text from right to left, left to right, up and down and down and up.
HTML Marquee
- <marquee behavior="alternate" scrolldelay="100"><marquee width="100">
- <h5 style="color:red; font-weight: bold; font-size: large;">Csharpcorner</h5>
- </marquee></marquee>
Marquee Type
- Right to left: <marquee>Csharpcorner</marquee>
- Left to right: <marquee direction="right">Csharpcorner</marquee>
- Down and up: <marquee direction="up">Csharpcorner</marquee>
- Up and down: <marquee direction="down">Csharpcorner</marquee>
JavaScript Marquee Funcation
- function scroll(pos)
- {
- var txt = "C-sharpcorner";
- var output = "";
- var screen = document.getElementById("wordscroller");
- for (var i = 0; i < pos; i++)
- {
- output += txt.charAt(i);
- }
- output += txt.charAt(pos);
- screen.innerHTML = output;
- pos++;
- if (pos != txt.length)
- {
- window.setTimeout(function () { scroll(pos); }, 200);
- }
- else
- {
- window.setTimeout(function () { scroll(0); }, 5000);
- }
- }


PikesPosted Feb 23, 2018, 12:18 AM
Is there a way to have text in the marquee where one word has color black and the second word is red?