HTML <marquee> Tag

The <marquee> is a non-standard HTML tag which was used to create a scrolling text or an image. It was used to make the text/image scroll horizontally across or vertically down the web page. Because of its usability problems it was often compared with Netscape’s blink element.

The <marquee> is a non-standard HTML tag which was used to create a scrolling text or an image. It was used to make the text/image scroll horizontally across or vertically down the web page.

The <marquee> element is a deprecated HTML tag. If you use this element, your pages or apps may be broken.

Alternatives of the HTML <marquee> tag

As it was said above, the HTML <marquee> tag is deprecated, and the developers often avoid using it. Nowadays, you can achieve the same result with the help of CSS and Javascript. Read our snippet to learn more about this method.

Syntax

The <marquee> element comes in pairs. It means that the tag has opening (<marquee>) and closing (</marquee>) elements.

Example of using HTML <marquee> tag:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      marquee{
      font-size: 30px;
      font-weight: 800;
      color: #8ebf42;
      font-family: sans-serif;
      }
    </style>
  </head>
  <body>
    <marquee>A scrolling text created with HTML Marquee element.</marquee>
  </body>
</html>

Use direction attribute of <marquee> element to change the direction of the text/image. See another example where the text scrolls from up to down.

Example of a scrolling text:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <marquee direction="down">A scrolling text created with HTML Marquee element.</marquee>
  </body>
</html>

Now let's see an example of using <marquee> element for setting a scrolling image:

Example of a scrolling image:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
     <marquee behavior="scroll" direction="up">
      <img src="/uploads/media/default/0001/01/0710cad7a1017902166203def268a0df2a5fd545.png" width="190" height="45" alt="W3docs" />
    </marquee>
  </body>
</html>

Use CSS width and background-color properties to style the <marquee> element.

Example of creating a scrolling text with HTML <marquee> tag:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <style> 
      marquee {
        width: 100%;
        padding: 10px 0;
        background-color: lightblue;
      }
    </style>
    <marquee direction="scroll">A scrolling text created with HTML Marquee element and styled with CSS properties.</marquee>
  </body>
</html>

Attributes

The following attributes can be used to adjust the appearance of the <marquee> element.

Attribute Value Description
behavior scroll
slide
alternate
Defines the scrolling type.
bgcolor rgb(x,x,x)
#xxxxxx
colorname
Is used to give a background color.
direction up
down
left
right
Sets the direction for the scrolling content.
height pixels
%
Defines the marquee's height.
hspace pixels Defines horizontal space around the marquee.
loop number Defines how many times the content will scroll. If we don't define this, the content will scroll forever.
scrollamount number Defines the scrolling amount at each interval in pixels. Default value is 6.
scrolldelay seconds Defines how long delay will be between each jump. The default value is 85 and smaller amounts than 60 will be ignored.
truespeed seconds Is used to delay the scroll lesser than 60.
vspace pixels Defines vertical space around the marquee.
width pixels
%
Defines the marquee's width.

The <marquee> tag also supports the the Global attributes and the Event Attributes.

How to style <marquee> tag

Common properties to alter the visual weight/emphasis/size of text in <marquee> tag:?

  • CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit
  • CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
  • CSS font-size property sets the size of the font.
  • CSS font-weight property defines whether the font should be bold or thick. CSS text-transform Property controls text case and capitalization.
  • CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style

Coloring text in <marquee> tag:

  • CSS color property describes the color of the text content and text decorations
  • CSS background-color property sets the background color of an element.

Text layout styles for <marquee> tag:

  • CSS text-indent property specifies the indentation of the first line in a text block.
  • CSS text-overflow property specifies how overflowed content that is not displayed should be signaled to the user.
  • CSS white-space property specifies how white-space inside an element is handled.
  • CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for <marquee> tag


Browser support



Do you find this helpful?

Related articles