how to create a simple news ticker using html, css and javascript

17/09/2020    By: christoper unum


News tickers can be used on a site to pass on important information to web users. In this tutorial, we will learn how to create a simple news ticker using marquee.


Basic knowledge of HTML, CSS and JavaScript is required to fully understand the concepts in this tutorial.


We begin by adding the HTML code as shown below

<div id="marquee-cont">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <td width="50px" style="background:#1174A8;">
        <button id="ticker-title">Posts:</button>
      <td id="marquee">
        <marquee onmouseover="this.stop();" onmouseout="this.start();" id='scroll'>
        temp <img src="" width="25px" />


Now we add styles 

#marquee-cont {
#marquee-cont marquee {
#marquee-news {
  padding:5px 20px;


Using JavaScript, we will render the content stored in the array in the marquee.

//array of news
const news = ["Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.",
"Contrary to popular belief, Lorem Ipsum is not simply random text.",
"The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested.",
"All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary."]

const logo = "<img src='' width='25px' style='margin:0 8px'/>";
let tickerText = "";
//looping through the news array
for(let i=0; i<news.length; i++){
  //adds the logo in between news items

document.querySelector("#scroll").innerHTML = tickerText;

Recent Posts

blog image
blog image
blog image

Our Newsletters