Marquee HTML W3Schools Example Tutorial Code Snippet

The marquee element is a fun and interactive way to add moving or scrolling text to your webpage. This HTML tag is particularly useful for creating eye-catching banners or highlighting important information. Let's explore how to use the marquee tag with some examples inspired by W3Schools.

Marquee in CSS - Beginner's Guide
Marquee in CSS - Beginner's Guide

Keyboard navigation is a crucial feature for any webpage, allowing users to interact with your site easily. The marquee tag supports several attributes, including the 'behavior' attribute, which dictates the movement of the text. 'scroll' is the default behavior, one of the most popular uses of the marquee tag. It scrolls the text from right to left across the screen.

Pure CSS 3D Marquee Text Animation Effect
Pure CSS 3D Marquee Text Animation Effect

Understanding the Marquee Tag

Firstly, you should understand what the marquee tag does. It's essentially an HTML wrapper that enables you to animate the text inside it. The text can scroll, move, or change direction based on the attributes you specify.

a computer screen with the text html and an image of a web page on it
a computer screen with the text html and an image of a web page on it

The marquee tag has several attributes, with 'behavior', 'direction', and 'scrollamount' being among the most commonly used. These attributes control how the text moves. 'Direction' determines the starting point of the scroll (left, right, up, down), 'behavior' tells the element how to move (scroll, slide, alternate), and 'scrollamount' sets the speed of the scroll.

Using the 'Direction' Attribute

an image of a web page with the words'body'and'reader '
an image of a web page with the words'body'and'reader '

The 'direction' attribute, especially, can be helpful when you want text to start from a specific direction. For example, the 'direction="left"' attribute would make the text start from the left side of the screen and move rightwards.

You could create a marquee as follows. This would make the text "Welcome to our website!" start from the left side of the screen and move rightwards.

<marquee behavior="scroll" direction="left">Welcome to our website!</marquee>

Using the 'Scrollamount' Attribute

18 Exciting HTML and CSS Project Ideas with source code to Level Up Your Web Development Skills
18 Exciting HTML and CSS Project Ideas with source code to Level Up Your Web Development Skills

Adjusting the 'scrollamount' attribute changes the speed at which the text moves. A higher number means faster movement, while a lower number means slower movement. Below is an example where the text scrolls slowly, with 'scrollamount="20"'.

<marquee behavior="scroll" direction="left" scrollamount="20">This text scrolls slowly</marquee>

Combining Marquee with Other HTML Elements

The marquee tag can be combined with other HTML elements to create more complex displays. For instance, you could place the marquee tag within a div or span to control the overall size and appearance of the marquee.

an image of a website page with the text'htmls'in white and green
an image of a website page with the text'htmls'in white and green

Another way to combine the marquee tag with other HTML elements is to include it within a list (ordered or unordered). This can display the marquee text as a list item, lending a more organized look to your webpage.

Marquee within a List

a blackboard with text and diagrams on it
a blackboard with text and diagrams on it
CSS-Only Marquee Effect | Codrops
CSS-Only Marquee Effect | Codrops
HTML Media Elements Explained – Images, Maps, Video & Audio in One Example
HTML Media Elements Explained – Images, Maps, Video & Audio in One Example
the before and after css web page is shown with an image of two screens
the before and after css web page is shown with an image of two screens
an image of a computer screen with the words html and css written in it
an image of a computer screen with the words html and css written in it
the ultimate guide to creating and using html - css projects for everyone
the ultimate guide to creating and using html - css projects for everyone
HTML simple code
HTML simple code
The 8 Best Sites for Quality HTML Coding Examples
The 8 Best Sites for Quality HTML Coding Examples
liMarquee - Horizontal and Vertical Scrolling of Text or Image or HTML Code free download
liMarquee - Horizontal and Vertical Scrolling of Text or Image or HTML Code free download
Blinking Text & Background With CSS
Blinking Text & Background With CSS
an image of a web page with different types of text and symbols on it, including the
an image of a web page with different types of text and symbols on it, including the
Login and Registration Form in HTML & CSS
Login and Registration Form in HTML & CSS
an image of the back side of a computer screen with text that reads, add css to html
an image of the back side of a computer screen with text that reads, add css to html
the basic html tag list is displayed in this screenshote screen graber, which shows
the basic html tag list is displayed in this screenshote screen graber, which shows
an image of a computer screen with some pictures on it and the text, color fuel
an image of a computer screen with some pictures on it and the text, color fuel
Création référencement site internet, graphisme, imprimerie
Création référencement site internet, graphisme, imprimerie
the types of gardient text on a black background with different colors and shapes
the types of gardient text on a black background with different colors and shapes
Monstro Galáctico
Monstro Galáctico
Cycle Completed! Prime Python, Java, JS Services: Loop Closed – Order for Infinite Innovations!
Cycle Completed! Prime Python, Java, JS Services: Loop Closed – Order for Infinite Innovations!
How To Create Rainbow Text Using CSS JS
How To Create Rainbow Text Using CSS JS

Here's an example that features a marquee tag within an ordered list. The text "First Item", "Second Item", and "Third Item" will scroll from right to left.

<ol>
  <li><marquee behavior="scroll">First Item</marquee></li>
  <li><marquee behavior="scroll">Second Item</marquee></li>
  <li><marquee behavior="scroll">Third Item</marquee></li>
</ol>

Finally, always remember that the marquee tag, while fun, should be used sparingly and with good taste. While it can add an interactive element to your page, overusing it can clutter your website and potentially distract visitors from the important content.

Related Articles

Html Links Tutorialspoint Html Tags Tutorialspoint Marquee Tag In Html Example How To Learn Html For Beginners Html Forms Tutorialspoint Pdf Html Tutorial Tutorialspoint Www Tutorialspoint Com Html Pdf Table Html Basics Html Table Tutorialspoint Tutorialspoint For Html