Amazing HTML <marquee> Tag in 2020: here is what you can use it

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

marquee tag
HTML marquee tag

The element is a deprecated HTML tag. If you use it, your pages or apps may be broken.

Alternatives of the HTML tag

As it was said above, the deprecated HTML 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 html tag comes in pairs. The content is written between the opening (<marquee>) and closing (</marquee>) tags.

How to use marquee tag in html:

HTML

<!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>lorem ipsum.</marquee>
  </body>
</html>

Example on codepen

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

How to use marquee tag in html for a scrolling text:

HTML

<!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 element for setting a scrolling image:

How to use marquee tag in html for scrolling image:

HTML

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
     <marquee behavior="scroll" direction="up">
      <img src="logo.jpg" width="190" height="45" alt="pennedweb" />
    </marquee>
  </body>
</html>

Use CSS width and background-color properties to style this element.

How to use marquee tag in html of creating a scrolling text:

HTML

<!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">This scrolling text is 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 element.

AttributeValueDescription
behaviorscroll
slide
alternate
Defines the scrolling type.
bgcolorrgb(x,x,x)
#xxxxxx
colorname
Is used to give a background color.
directionup
down
left
right
Sets the direction for the scrolling content.
heightpixels
%
Defines the marquee’s height.
hspacepixelsDefines horizontal space around the marquee.
loopnumberDefines how many times the content will scroll. If we don’t define this, the content will scroll forever.
scrollamountnumberDefines the scrolling amount at each interval in pixels. Default value is 6.
scrolldelaysecondsDefines how long delay will be between each jump. The default value is 85 and smaller amounts than 60 will be ignored.
truespeedsecondsIs used to delay the scroll lesser than 60.
vspacepixelsDefines vertical space around the marquee.
widthpixels
%
Defines the marquee’s width.

The html tag also supports the Global attributes and the Event Attributes.

How to use marquee tag in CSS?

Common properties to alter the visual weight/emphasis/size of text in 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.

How to use marquee tag in CSS Coloring text:

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

How to use marquee tag in CSS Text layout styles:

  • 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 signalled 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 how to use marquee tag in CSS:

  • CSS text-shadow property adds shadow to text.
  • CSS text-align-last property sets the alignment of the last line of the text.
  • CSS line-height property specifies the height of a line.
  • CSS letter-spacing property defines the spaces between letters/characters in a text.
  • CSS word-spacing property sets the spacing between words.

Just for fun watch the cute cats compilation:

Leave a Reply