Moving Text in HTML
Moving text in HTML is also said to be scrolling text. We can scroll the text in all directions with a certain speed of time interval.
Real-Time Example: Let’s consider we have important updated content on our website frequently. If that content is always stable, users can’t attend to the content, so to get the user’s attention, we have to scroll the updated content always. Depending upon user requirement, we can give direction to which side content scroll. Achieve this requirement
Why we use CSS in HTML?
Provide common Logic between all the pages; instead of writing the same style logic in each HTML page, we use a CSS file for writing common logic. And include this CSS page in each HTML page with tag.
How does the Marquee tag work in HTML?
Content can be moved by applying
Syntax #1
<marquee> //some text to move </marquee>
Syntax #2
<marquee direction=”left or right or up or down”> //some text to move </marquee>
Syntax #3
<marquee behavior="alternate"> //it makes the text back direction by touching the border of the page. //some text to move </marquee>
Syntax #4
<marquee direction=”left” scrollamount="5">// scrollamount used to set the scrolling text speed //some text to move </marquee>Note: Default marquee direction is right to leave if we did not provide any direction property.
Examples to Implement Moving Text in HTML
Below are the examples mentioned:
Example #1
Default marquee tag
Code:
<!DOCTYPE html> <html> <head> <title>Move Text</title> <style> body { background-color: green; text-align: center; color: white; font-family: Arial; } </style> </head> <body> <h1>Moving Text with Marquee Tag</h1> <marquee> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee> </body> </html>
Output:
Explanation: As you can see in the above text moved from right to left even we did not mention any direction, so it is the default marquee tag.
Example #2
Marquee tag in the right direction.
Code:
<!DOCTYPE html> <html> <head> <title>Move Text</title> <style> body { background-color: maroon; text-align: center; color: white; font-family: Arial; } </style> </head> <body> <h1>Moving Text with Marquee Tag</h1> <marquee direction="right"> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee> </body> </html>
Output:
Explanation: As you can see in the above text, moved from left to right by setting direction property to the right.
Example #3
Marquee in the top direction
Code:
<!DOCTYPE html> <html> <head> <title>Move Text</title> <style> body { background-color: blue; text-align: center; color: white; font-family: Arial; } </style> </head> <body> <h1>Moving Text with Marquee Tag</h1> <marquee direction="up"> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee> </body> </html>
Output:
Explanation: As you can see in the above text, moved from bottom to top by setting direction property to up.
Example #4
Marquee in the bottom direction.
Code:
<!DOCTYPE html> <html> <head> <title>Move Text</title> <style> body { background-color: orange; text-align: center; color: white; font-family: Arial; } </style> </head> <body> <h1>Moving Text with Marquee Tag</h1> <marquee direction="down"> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee> </body> </html>
Output:
Explanation: As you can see in the above text, moved from top to bottom by setting direction property to down.
Example #5
Marquee with behavior property.
Code:
<!DOCTYPE html> <html> <head> <title>Move Text</title> <style> body { background-color: lightblue; text-align: center; color: brown; font-family: Arial; border: solid 2px red; } </style> </head> <body> <h1>Moving Text with Marquee Tag</h1> <marquee behavior="alternate"> Hi, I am an alternate proeprty </marquee> </body> </html>
Output:
Explanation: As you can see in the above text, moved from left to right and right-left by touching the border by setting behavior property to alternate.
Example #6
Marquee with scroll amount property.
Code:
<!DOCTYPE html> <html> <head> <title>Move Text</title> <style> body { background-color: fuchsia; text-align: center; color: white; font-family: Arial; border: solid 2px red; } </style> </head> <body> <h1>Moving Text with Marquee Tag</h1> <marquee direction="left" scrollamount="2"> Paramesh </marquee> <marquee scrollamount="4"> Amardeep </marquee> <marquee scrollamount="6"> Harinath-Rajitha </marquee> </body> </html>
Output:
Explanation: As you can see in the above text moved from right to left with different timings, so they are all at different positions.
Conclusion
Moving text in HTML achieved by the marquee tag. We can move the text in left, right, up and down based on the requirement. This marquee feature mostly used by TV channels for a regular update to capture user attention.
The above is the detailed content of Moving Text in HTML. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To get the user's current location, use the HTML5 GeolocationAPI. This API provides information such as latitude and longitude after user authorization. The core method is getCurrentPosition(), which requires successful and error callbacks to be handled; at the same time, pay attention to the HTTPS prerequisite, user authorization mechanism and error code processing. ① Call getCurrentPosition to get the position once, and an error callback will be triggered if it fails; ② The user must authorize it, otherwise it cannot be obtained and may no longer be prompted; ③ Error processing should distinguish between rejection, timeout, location unavailable, etc.; ④ Enable high-precision, set timeout time, etc., and can be configured through the third parameter; ⑤ The online environment must use HTTPS, otherwise it may be restricted by the browser.

The difference between async and defer is the execution timing of the script. async allows scripts to be downloaded in parallel and executed immediately after downloading, without guaranteeing the execution order; defer executes scripts in order after HTML parsing is completed. Both avoid blocking HTML parsing. Using async is suitable for standalone scripts such as analyzing code; defer is suitable for scenarios where you need to access the DOM or rely on other scripts.

The core difference between localStorage and sessionStorage lies in data persistence and scope. 1. Data life cycle: localStorage data is stored for a long time unless manually cleared, and sessionStorage data is cleared after closing the tab; 2. Scope difference: localStorage is shared among all tabs on the same website, and sessionStorage is stored independently; 3. Usage scenario: localStorage is suitable for saving long-term data such as user preferences and login status, sessionStorage is suitable for temporary form data or single session process; 4. API consistency: two operation methods

The key to using radio buttons in HTML5 is to understand how they work and correctly organize the code structure. 1. The name attribute of each radio button must be the same to achieve mutually exclusive selection; 2. Use label tags to improve accessibility and click experience; 3. It is recommended to wrap each option in a div or label to enhance structural clarity and style control; 4. Set default selections through the checked attribute; 5. The value value should be concise and meaningful, which is convenient for form submission processing; 6. The style can be customized through CSS, but the function needs to be ensured to be normal. Mastering these key points can effectively avoid common problems and improve the effectiveness of use.

Yes, it is part of HTML5, but its use has gradually decreased and is controversial. Used to combine the main title with the subtitle so that only the highest level of titles are identified in the document outline; for example, the main title and subtitle can be wrapped in to indicate that they are only auxiliary titles rather than independent chapter titles; however, reasons why they are no longer widely used include: 1. The browser and screen readers are inconsistent support for them, 2. There are simpler alternatives such as using CSS to control styles, 3. The HTML document outline algorithm is not widely supported; despite this, it can still be considered in websites or documents with high semantic requirements; while in most cases, developers tend to use a single, manage styles through CSS and maintain clear title levels.

To correctly set the character encoding of the HTML document to UTF-8, you need to follow three steps: 1. Add at the top of the HTML5 part; 2. Configure the response header Content-Type: text/html; charset=UTF-8, if Apache uses AddDefaultCharsetUTF-8, Nginx uses charsetutf-8; 3. Select the UTF-8 encoding format when saving HTML files in the editor. These three links are indispensable, otherwise it may lead to garbled page code and failure of special character parsing, affecting user experience and SEO effect. It is important to ensure that HTML declaration, server configuration and file saving are consistent.

ShadowDOM is a technology used in web component technology to create isolated DOM subtrees. 1. It allows the mount of an independent DOM structure on ordinary HTML elements, with its own styles and behaviors, and does not affect the main document; 2. Created through JavaScript, such as using the attachShadow method and setting the mode to open; 3. When used in combination with HTML, it has three major features: clear structure, style isolation and content projection (slot); 4. Notes include complex debugging, style scope control, performance overhead and framework compatibility issues. In short, ShadowDOM provides native encapsulation capabilities for building reusable and non-polluting UI components.

It is a block-level element, used to divide large block content areas; it is an inline element, suitable for wrapping small segments of text or content fragments. The specific differences are as follows: 1. Exclusively occupy a row, width and height, inner and outer margins can be set, which are often used in layout structures such as headers, sidebars, etc.; 2. Do not wrap lines, only occupy the content width, and are used for local style control such as discoloration, bolding, etc.; 3. In terms of usage scenarios, it is suitable for the layout and structure organization of the overall area, and is used for small-scale style adjustments that do not affect the overall layout; 4. When nesting, it can contain any elements, and block-level elements should not be nested inside.
