search
HomeWeb Front-endHTML TutorialWhat is the code for scroll bar in html? How to set html scroll bar?

This article mainly introduces the code of the scroll bar in html, as well as the usage of the marquee tag attribute of the html scroll bar code. Let us take a look at this article in detail

First we introduce the scroll bar code in html:

Today we introduce that the html scroll bar label is marquee.

label, which is a label that appears in pairs , the content between the first tag and the last tag is the scrolling content. The attributes of the tag mainly include behavior, bgcolor, direction, width, height, hspace, vspace, loop, scrollamount, scrolldelay, etc. They are all optional.

Now let’s talk about setting the HTML scroll bar:

At this time, let’s take a look at how the marquee tag uses its attributes to implement the html scroll bar.

1.html The behavior attribute of the marquee tag:

The parameter value of the behavior attribute is one of alternate, scroll, and slide, which respectively indicates that the text scrolls back and forth and in one direction. Cyclic scrolling, scrolling only once, it should be noted that if the direction and behavior attributes appear in the tag at the same time, then the scrolling direction of scroll and slide will be based on the setting of the parameters in the direction attribute.

<marquee behavior="alternate">我来回滚动</marquee> 
<marquee behavior="scroll">我单方向循环滚动</marquee>
<marquee behavior="scroll" direction="up" height="30">我改单方向向上循环滚动</marquee> 
<marquee behavior="slide">我只滚动一次</marquee> 
<marquee behavior="slide" direction="up">我改向上只滚动一次了</marquee>

The styles are very nice, and they are all dynamic. Screenshots cannot be taken. If you are interested, you can practice it here. Just copy the above code and then go to http://www.php.cn/ Paste code/26516.html here and you can see the effect immediately. You don’t need to complete the code to display it. You can display a lot of things you want to see here.

This is just one of the attributes. There are several more attributes. Let’s take a look at them:

2.html marquee tag bgcolor attribute:

The background color of the text scrolling range. The parameter value is hexadecimal (form: #AABBCC or #AA5566, etc.) or a predefined color name (such as red, yellow, blue, etc.) . As shown below:

<marquee behavior=="slide" direction="left" bgcolor="red">我的背景色是红色的</marquee>

3.html The direction attribute of the marquee tag:

The direction of text scrolling. The parameter values ​​of the attribute include down, left, right, and up. Four single optional values, representing the scrolling direction down, left, right, and up respectively. As shown below:

    <marquee direction="right">我向右滚动</marquee> 
    <marquee direction="right">我向下滚动</marquee>

4.html The width and height attributes of the marquee tag:

The functions of the width and height attributes determine the size of the rectangular range of the scrolling text on the page . The width attribute is used to specify the width of the rectangle, and the height attribute specifies the height of the rectangle. The parameter value of these two properties can be a number or a percentage. The number represents the number of pixels (width or height) occupied by the rectangle, and the percentage represents the percentage (width or height) of the browser window occupied by the rectangle. As shown below:

    <marquee width="300" height="30" bgcolor="red">我宽300像素,高30像素。</marquee>

5.html The scrollamount and scrolldelay attributes of the marquee tag:

These two attributes determine the speed of text scrolling (scrollamount) and delay ( scrolldelay), the parameter values ​​are all positive integers. As shown below:

    <marquee scrollamount="100">我速度很快.</marquee> 
    <marquee scrollamount="50">我慢了些。</marquee> 
    <marquee scrolldelay="30">我小步前进。</marquee> 
    <marquee scrolldelay="1000" scrollamount="100">我大步前进。</marquee>

6.html The align attribute of the marquee tag:

This attribute determines the position of the scrolling text at the top, bottom, left and right of the inner border. You can also replace the content between and with features such as images or other objects.

Notes on html marquee tags:

The default width of a marquee element is equal to the width of its parent element. If the marquee is inside a td that does not have a specified width, you will need to set the width of the marquee explicitly. If neither marquee nor td width is specified, the scrolling marquee will be limited to 1 pixel wide.

To create vertically scrolling subtitles, set its scrollLeft property to 0. To create a horizontally scrolling subtitle, set its scrollTop property to 0, which overrides any script settings.

scrollLeft and scrollTop properties are read-only when the subtitles are scrolling. When not in the scrolling state, scrollLeft is readable and writable for subtitles set to horizontal scrolling, and scrolltop is readable and writable for subtitles set to vertical scrolling.

This element is available in HTML in Microsoft® Internet Explorer 3.0 and in script in Internet Explorer 4.0.

This element is a block element.

This element requires a closing tag.

【Editor’s Recommendation】

How to add underline in HTML? Usage example of adding underline to html tag

How to set the style of html button tag? Introduction to the style of html button tag

The above is the detailed content of What is the code for scroll bar in html? How to set html scroll bar?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Atom editor mac version download

Atom editor mac version download

The most popular open source editor