Detailed explanation of HTML marquee (text scrolling)
The marquee tag in HTML is used to create scrolling text effects. It allows text to automatically scroll on a webpage, grabbing the user’s attention. Here is a detailed explanation of the marquee tag.
- Tag attribute:
- Behavior refers to the specified scrolling method. Options include “scroll” (default, text scrolls from one side to the other), “slide” (text slides in from one side and then slides out from the other), and “alternate” (text alternates between scrolling back and forth on both sides).
- Specify the scrolling direction. Options include “left” (scrolling from right to left), “right” (scrolling from left to right), “up” (scrolling from bottom to top), and “down” (scrolling from top to bottom).
- Loop: specifies the number of times to scroll. Options include numbers (indicating the number of scrolls) or “infinite” for endless scrolling.
- Scrollamount: specifies the scrolling speed; the optional value is a positive integer (indicating the number of pixels scrolled per second).
- The scroll delay is set to specify the time interval between two scrollings, measured in milliseconds and represented by a positive integer.
- bgcolor: Specifies the background color.
- Specify the width of the tag.
- height: specifies the height of the tag.
- Example of Usage:
<marquee behavior="scroll" direction="left">这是滚动的文字</marquee>
In the example above, the text will scroll from right to left.
- Notice:
- The marquee tag has been deprecated in HTML5 and is not recommended for use in new projects. It is advised to use CSS animations or JavaScript to achieve scrolling effects.
- The scrolling text should be short and lengthy scrolling may potentially annoy users.
- The support for the marquee tag varies among different browsers, which may result in inconsistent display effects.