Login
Your Email
Pasword
Home
Write
Trending
History
Liked
Dashboard

What is HTML?Guide for new learners

HTML is the markup language for creating Web pages.

Do you have similar website/ Product?
Show in this page just for only $2 (for a month)
Create an Ad
0/60
0/180
HTML stands for Hyper Text Markup Language.It describes the structure of Web pages using markup. HTML elements are the building blocks of HTML pages and they are represented by tags.
HTML tags label pieces of content such as "heading", "paragraph", "table" 
It doesn't  display the HTML tags on the browsers but use them to render the content of the page.
Example of a HTML Document:



My first webpage


Heading of my 1st wepage


This is my first paragraph of web page




The is the declaration that defines this document to be HTML5 
The element is the root element of an HTML page 
The  element contains meta information about the document The element contains the title of the page<br></div><div class="tableWr">The <body> element consist of all the visible contents of web page.<br></div><div class="tableWr"><h1> element defines the large heading.</div><div class="tableWr">The<p> defines the paragraph in web page.</div><div class="tableWr"><br></div><div class="tableWr"></div></div></body></html> </div> <div id="continue"> <div id="continue_read">CONTINUE READING</div> </div> <div id="keywords"><a href="https://newsandstory.com/topic/html/"><div class="kwwr"><div class="kw">HTML</div></div></a></div> <div id="icatagory"><div class="cawr"> <div class="ca">Learning</div> </div></div> <div id="sa"> <div class="saimg"><i class="user-avatar fa fa-user fa-2x" aria-hidden="true"></i></div> <div class="sadetails"> <div id="san">Ayesha</div> <div id="sad">Tech writer at newsandstory</div> </div> </div> <input type="hidden" id="countvalue" value="2374"> <!-- <div id="sv">Total <b>2374</b> views </div> --> <div id="bottom adds"> </div> </div> <div id="similarwr"> <div id="adds"> </div> <div id="similaritemwr"> <div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/110611112819201854693/how-to-apply-formatting-on-html-elements/" >How to apply Formatting on HTML Elements?</a></div> </div> <div class="similarimagewr"> <a href="/story/110611112819201854693/how-to-apply-formatting-on-html-elements/"><div class="simlarimage lazyload" data-bg="/stories/110611112819201854693/110611112819201854693.png-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/0307373915201847131/what-is-xhtml-and-why-we-use-it/" >What is XHTML and why we use it?</a></div> </div> <div class="similarimagewr"> <a href="/story/0307373915201847131/what-is-xhtml-and-why-we-use-it/"><div class="simlarimage lazyload" data-bg="/stories/0307373915201847131/0307373915201847131.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/200620172452201893099/what-are-html-elements/" >What are HTML Elements? </a></div> </div> <div class="similarimagewr"> <a href="/story/200620172452201893099/what-are-html-elements/"><div class="simlarimage lazyload" data-bg="/stories/200620172452201893099/200620172452201893099.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/230623170455201885045/what-is-html-css-and-why-to-use-it/" >What is HTML CSS and why to use it?</a></div> </div> <div class="similarimagewr"> <a href="/story/230623170455201885045/what-is-html-css-and-why-to-use-it/"><div class="simlarimage lazyload" data-bg="/stories/230623170455201885045/230623170455201885045.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/200620165907201814389/how-to-write-html-using-notepad-or-textedit/" >How to write HTML Using Notepad or TextEdit?</a></div> </div> <div class="similarimagewr"> <a href="/story/200620165907201814389/how-to-write-html-using-notepad-or-textedit/"><div class="simlarimage lazyload" data-bg="/stories/200620165907201814389/200620165907201814389.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/21062184742201828485/what-are-html-attributes-and-how-to-use-them/" >What are HTML attributes and how to use them?</a></div> </div> <div class="similarimagewr"> <a href="/story/21062184742201828485/what-are-html-attributes-and-how-to-use-them/"><div class="simlarimage lazyload" data-bg="/stories/21062184742201828485/21062184742201828485.png-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/04074172445201859124/how-to-add-plug-ins-in-html/" >How to add Plug-ins in HTML?</a></div> </div> <div class="similarimagewr"> <a href="/story/04074172445201859124/how-to-add-plug-ins-in-html/"><div class="simlarimage lazyload" data-bg="/stories/04074172445201859124/04074172445201859124.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/0307372250201881863/what-is-html-encoding/" >What is HTML Encoding? </a></div> </div> <div class="similarimagewr"> <a href="/story/0307372250201881863/what-is-html-encoding/"><div class="simlarimage lazyload" data-bg="/stories/0307372250201881863/0307372250201881863.png-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/210621173843201832772/how-to-use-html-styles/" >How to use HTML Styles?</a></div> </div> <div class="similarimagewr"> <a href="/story/210621173843201832772/how-to-use-html-styles/"><div class="simlarimage lazyload" data-bg="/stories/210621173843201832772/210621173843201832772.png-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/0207284321201819655/what-are-the-computer-code-elements-in-html/" >What are the Computer Code Elements in HTML?</a></div> </div> <div class="similarimagewr"> <a href="/story/0207284321201819655/what-are-the-computer-code-elements-in-html/"><div class="simlarimage lazyload" data-bg="/stories/0207284321201819655/0207284321201819655.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/04074171540201825773/how-to-add-audio-in-html/" >How to add Audio in HTML?</a></div> </div> <div class="similarimagewr"> <a href="/story/04074171540201825773/how-to-add-audio-in-html/"><div class="simlarimage lazyload" data-bg="/stories/04074171540201825773/04074171540201825773.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/260426171236201879546/13-died-in-india-while-the-bus-driver-was-enjoying-music/">13 died in India while the bus driver was enjoying music</a></div> </div> <div class="similarimagewr"> <a href="/story/260426171236201879546/13-died-in-india-while-the-bus-driver-was-enjoying-music/" ><div class="simlarimage lazyload" data-bg="/stories/260426171236201879546/260426171236201879546.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/05085172242201879546/decrease-in-india-us-trade-deficit/">Decrease in India-US trade deficit</a></div> </div> <div class="similarimagewr"> <a href="/story/05085172242201879546/decrease-in-india-us-trade-deficit/" ><div class="simlarimage lazyload" data-bg="/stories/05085172242201879546/05085172242201879546.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/txbzApg/secondary-memory-magnetic-storage-and-it-s-uses-module-35/">Secondary memory : Magnetic storage and it's uses (module 35)</a></div> </div> <div class="similarimagewr"> <a href="/story/txbzApg/secondary-memory-magnetic-storage-and-it-s-uses-module-35/" ><div class="simlarimage lazyload" data-bg="/stories/txbzApg/txbzApg.jpg-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/08058144403201897437/setting-up-youtube-channel/">Setting up youtube channel</a></div> </div> <div class="similarimagewr"> <a href="/story/08058144403201897437/setting-up-youtube-channel/" ><div class="simlarimage lazyload" data-bg="/stories/08058144403201897437/08058144403201897437.png-300-160-50000.webp"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/HYvbf/the-art-of-style-elevate-your-wardrobe-with-fashion-jackets/">The Art of Style: Elevate Your Wardrobe with Fashion Jackets</a></div> </div> <div class="similarimagewr"> <a href="/story/HYvbf/the-art-of-style-elevate-your-wardrobe-with-fashion-jackets/" ><div class="simlarimage lazyload" data-bg="/"></div></a> </div> </div><div class="siw"> <div class="similartitlewr"> <div class="similartitle"><a href="/story/140714194729201897571/quot-role-of-search-engine-optimization-seo-in-web-design-quot/">"ROLE OF SEARCH ENGINE OPTIMIZATION (SEO) IN WEB DESIGN".</a></div> </div> <div class="similarimagewr"> <a href="/story/140714194729201897571/quot-role-of-search-engine-optimization-seo-in-web-design-quot/" ><div class="simlarimage lazyload" data-bg="/stories/140714194729201897571/140714194729201897571.jpg-300-160-50000.webp"></div></a> </div> </div> </div> <div id="subscribe_wr"> <div class="subscribe"> <div class="subscribe_item subscribe_brand">NewsAndStory</div> <div class="subscribe_item subscribe_headline">Subscribe to get latest update</div> <div class="subscribe_item subscribe_subheadline">Subscription is completely free</div> <div class="subscribe_item subscribe_email"><input class="subscribe_iemail" placeholder=" Enter your email"></div> <div class="subscribe_item subscribe_submit"><button class="subscribe_submitbtn">SUBMIT</button></div> </div> </div> <div class="adds"> </div> </div> <div id="footer"> <div id="footerup"></div> <div id="footermiddle"> <div id="footermiddlewrapper"> <div class="footermiddlebox one"> <div class="fmb"><a href="/about/">About us</a></div> <!-- <div class="fmb"><a href="/faq/">FAQs</a></div> --> <!-- <div class="fmb"><a href="/terms/">Terms of use</a></div> --> <!-- <div class="fmb"><a href="/privacy/">Cookie and privacy</a></div> --> </div> <div class="footermiddlebox two"> <div class="fmb"><a href="/editor/">Publish Sponsored Article</a></div> <!-- <div class="fmb"><a href="/advertise.php">Advertise with us</a></div> --> <!-- <div class="fmb"><a href="/monetize/">Monetize your contents</a></div> --> <!-- <div class="fmb"><a href="/carrer/">Careers </a></div> --> </div> <div class="footermiddlebox three"> <!-- <div class="fmb"><a href="/feedback/">Feedback</a></div> --> <div class="fmb"><a href="/contact/">Contact</a></div> <!-- <div class="fmb"><a href="/carrer/">Work for us</a></div> --> <!-- <div class="fmb"><a href="/share/">Share your feelings</a></div> --> </div> </div> </div> <div id="footerdown"> <div id="copyright"> <div id="copyrighttext">© www.newsandstory.com</div> </div> </div> </div> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-83852986-1', 'auto'); ga('send', 'pageview'); </script> <script type="text/javascript"> function ajaxObj(meth, url){ var x=new XMLHttpRequest(); x.open(meth,url,true); x.setRequestHeader("Content-type","application/x-www-form-urlencoded"); return x; }//////end of ajaxObj function function ajaxReturn(x){ if(x.readyState==4 && x.status==200){ return true } }//////end of ajaxReturn function ////Usage </script> </body> <!--Javacript to show link inside the story --> <script type="text/javascript"> function findMainChild(storycontent) { if (storycontent.hasChildNodes()) { var storyChildren = storycontent.children } if (storyChildren.length < 5) { //return storyChildren; for (let m = 0; m < storyChildren.length; m++) { if (storyChildren[m].hasChildNodes() && storyChildren[m].innerText.length > 200) { return findMainChild(storyChildren[m]) } } } else { return storyChildren; } } (async function() { let similarTitled = [{"id":"465","uid":"200620172452201893099","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What are HTML Elements? ","shortdescription":"An HTML element consists of a start tag and end tag with the content inserted in between.","storycontent":"https:\/\/newsandstory.com\/story\/200620172452201893099\/what-are-html-elements\/","mainimage":"200620172452201893099.jpg","keywords":"HTML, Elements","catagory":"HTML ","writing":"2018-06-20 17:24:52","lastUpdate":"2018-06-20 17:24:52","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125228720128,"url":"https:\/\/newsandstory.com\/story\/200620172452201893099\/what-are-html-elements\/"},{"id":"483","uid":"230623175325201837570","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What are HTML Iframes?","shortdescription":"An iframe is used to display a web page within a web page.","storycontent":"https:\/\/newsandstory.com\/story\/230623175325201837570\/what-are-html-iframes\/","mainimage":"230623175325201837570.png","keywords":" Iframes , HTML","catagory":"HTML","writing":"2018-06-23 17:53:25","lastUpdate":"2018-06-23 17:53:25","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125263323136,"url":"https:\/\/newsandstory.com\/story\/230623175325201837570\/what-are-html-iframes\/"},{"id":"495","uid":"0307353038201865756","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What are HTML Entities?","shortdescription":"Reserved characters in HTML must be replaced with character entities.Characters that are not present on your keyboard can be replaced by entities.","storycontent":"https:\/\/newsandstory.com\/story\/0307353038201865756\/what-are-html-entities\/","mainimage":"0307353038201865756.jpg","keywords":"Entities","catagory":"HTML","writing":"2018-07-03 05:30:38","lastUpdate":"2018-07-03 05:34:22","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125298974720,"url":"https:\/\/newsandstory.com\/story\/0307353038201865756\/what-are-html-entities\/"},{"id":"497","uid":"0307372250201881863","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What is HTML Encoding?\n","shortdescription":"To display an HTML page correctly, a web browser must know which character encoding to use.","storycontent":"https:\/\/newsandstory.com\/story\/0307372250201881863\/what-is-html-encoding\/","mainimage":"0307372250201881863.png","keywords":" Encoding","catagory":"HTML ","writing":"2018-07-03 07:22:50","lastUpdate":"2018-07-03 07:22:50","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125300023296,"url":"https:\/\/newsandstory.com\/story\/0307372250201881863\/what-is-html-encoding\/"},{"id":"498","uid":"0307373045201842309","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What is HTML URL?","shortdescription":"Uniform Resource Locators is another word for a web address.","storycontent":"https:\/\/newsandstory.com\/story\/0307373045201842309\/what-is-html-url\/","mainimage":"0307373045201842309.jpg","keywords":"URL","catagory":"Html","writing":"2018-07-03 07:30:45","lastUpdate":"2018-07-03 07:30:45","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125307363328,"url":"https:\/\/newsandstory.com\/story\/0307373045201842309\/what-is-html-url\/"},{"id":"500","uid":"0307390650201816562","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What are HTML Forms?","shortdescription":"Form elements are different types of input elements, like text fields, checkboxes, radio buttons, submit buttons, and more.","storycontent":"https:\/\/newsandstory.com\/story\/0307390650201816562\/what-are-html-forms\/","mainimage":"0307390650201816562.png","keywords":"Forms","catagory":"HTML","writing":"2018-07-03 09:06:50","lastUpdate":"2018-07-03 09:14:28","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125308411904,"url":"https:\/\/newsandstory.com\/story\/0307390650201816562\/what-are-html-forms\/"},{"id":"507","uid":"0407492509201850336","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":" Tech writer at newsandstory ","title":"Waht is HTML Multimedia?","shortdescription":"Multimedia on the web is sound, music, videos, movies, and animations.","storycontent":"https:\/\/newsandstory.com\/story\/0407492509201850336\/waht-is-html-multimedia\/","mainimage":"0407492509201850336.jpg","keywords":" Multimedia","catagory":" HTML Multimedia","writing":"2018-07-04 09:25:09","lastUpdate":"2018-07-04 09:25:09","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125316800513,"url":"https:\/\/newsandstory.com\/story\/0407492509201850336\/waht-is-html-multimedia\/"},{"id":"476","uid":"210621173843201832772","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"How to use HTML Styles?","shortdescription":"Setting the style of an HTML element is done with the style attribute","storycontent":"https:\/\/newsandstory.com\/story\/210621173843201832772\/how-to-use-html-styles\/","mainimage":"210621173843201832772.png","keywords":"HTML , Styles","catagory":"HTML Styling","writing":"2018-06-21 17:38:43","lastUpdate":"2018-06-21 17:38:43","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125251788800,"url":"https:\/\/newsandstory.com\/story\/210621173843201832772\/how-to-use-html-styles\/"},{"id":"480","uid":"230623171855201865508","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"How to add HTML Tables?","shortdescription":"An HTML table is defined with the &lt;table&gt; tag to add table on the web page.","storycontent":"https:\/\/newsandstory.com\/story\/230623171855201865508\/how-to-add-html-tables\/","mainimage":"230623171855201865508.gif","keywords":"HTML , Tables","catagory":"Styling","writing":"2018-06-23 17:18:55","lastUpdate":"2018-06-23 17:18:55","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125261225984,"url":"https:\/\/newsandstory.com\/story\/230623171855201865508\/how-to-add-html-tables\/"},{"id":"482","uid":"230623174122201832791","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What is the id Attribute in HTML?","shortdescription":"The id attribute specifies a unique id for an HTML element .","storycontent":"https:\/\/newsandstory.com\/story\/230623174122201832791\/what-is-the-id-attribute-in-html\/","mainimage":"230623174122201832791.jpg","keywords":"id Attribute , JavaScript","catagory":" HTML","writing":"2018-06-23 17:41:22","lastUpdate":"2018-06-23 17:41:22","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125262274561,"url":"https:\/\/newsandstory.com\/story\/230623174122201832791\/what-is-the-id-attribute-in-html\/"},{"id":"493","uid":"0207282242201833116","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"What are File Paths in HTML?","shortdescription":"A file path describes the location of a file in a folder structure of web site.","storycontent":"https:\/\/newsandstory.com\/story\/0207282242201833116\/what-are-file-paths-in-html\/","mainimage":"0207282242201833116.png","keywords":"File Paths","catagory":"HTML","writing":"2018-07-02 08:22:42","lastUpdate":"2018-07-02 08:22:42","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125288488960,"url":"https:\/\/newsandstory.com\/story\/0207282242201833116\/what-are-file-paths-in-html\/"},{"id":"496","uid":"0307355934201888370","userid":"30","email":"Ayesha@gmail.com","aname":"Ayesha","adesignation":"Tech writer at newsandstory","title":"How to add HTML Symbols?","shortdescription":"Many mathematical, technical, and currency symbols, are not present on a normal keyboard.To add such symbols to an HTML page use an HTML entity name.","storycontent":"https:\/\/newsandstory.com\/story\/0307355934201888370\/how-to-add-html-symbols\/","mainimage":"0307355934201888370.png","keywords":"Symbols","catagory":"HTML ","writing":"2018-07-03 05:59:34","lastUpdate":"2018-07-03 05:59:34","paid":"0","activated":"1","indexed":"0","deleted":"0","_version_":1751734125298974721,"url":"https:\/\/newsandstory.com\/story\/0307355934201888370\/how-to-add-html-symbols\/"}]; let storycontent = document.getElementById('editordiv'); let storyChildren = findMainChild(storycontent); let j = 1; for (let i = 0; i < storyChildren.length; i++) { if (i % 2 == 0 && storyChildren[i].nodeName.toLowerCase() == "div" && j < similarTitled.length && storyChildren[ i].innerText .length > 200) { j = j + 1; storyChildren[i].innerHTML = storyChildren[i].innerHTML + `<div class=read-wr> <span class="read">Read: </span><a href="${similarTitled[j].url}">${similarTitled[j].title}</a><div>`; } if (j > 8) { break; } if (i == 1) { storyChildren[i].innerHTML = storyChildren[i].innerHTML + `<a href="/editor/" style="text-decoration:none;"><div style="width: 100%; height: 150px; background-color: #235323; display: flex; justify-content: center; align-items: center; color: white; font-size: 1.3rem; cursor: pointer;">Publish Your Success Story</div></a>`; } } })(); </script> <script type="text/javascript"> addelistener(); addsleftlistener(); addserchkeylistener(); </script> <noscript> <link rel="stylesheet" type="text/css" href="/prism/prism.css" /> </noscript> <script type="text/javascript"> document.getElementById('continue_read').addEventListener('click', showFullStory, false); function showFullStory() { document.getElementById('sn').style.setProperty("max-height", "none"); document.getElementById('continue').style.setProperty("display", "none"); } </script> <!-- Lazy load images and register unload event---> <script type="text/javascript"> (async function() { var images = document.getElementById('editordiv').getElementsByTagName('img'); for (var i = 0; i < images.length; i++) { images[i].loading = "lazy" if (!images[i].getAttribute('alt')) { images[i].setAttribute('alt', `HTML`) } } })(); window.addEventListener('pagehide', saveStoryRead, false); function getClass(className) { return document.getElementsByClassName(className)[0] } function saveStoryRead() { localStorage.setItem("lastread", JSON.stringify({ url: window.location.href, title: getClass('st') })); } </script> <!-- lazy load CSS --> <script> (function() { // load main.css // load fontawesome var cssFa = document.createElement('link'); cssFa.href = '/prism/prism.css'; cssFa.rel = 'stylesheet'; cssFa.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(cssFa); })(); </script> <script type="text/javascript"> (async function() { document.addEventListener('lazybeforeunveil', function(e) { var bg = e.target.getAttribute('data-bg'); if (bg) { e.target.style.backgroundImage = 'url(' + bg + ')'; } }); })(); </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script> <script type="text/javascript"> //window.addEventListener("load", getRelated, false); //window.addEventListener("load", getAds, false); getAds(); getRelated(); document.getElementsByClassName('subscribe_submitbtn')[0].addEventListener("click", subscribe, false); async function getRelated() { var storyId = "200620123713201889688"; var related = await axios.post("/related.php", { id: storyId }) } async function getAds() { var storyId = "200620123713201889688"; var ads = await axios.post("https://core.newsandstory.com/get-ads", { id: storyId }) if (ads.data.status == "success" && ads.data.ads.length > 0) { let adsdata = ads.data.ads; for (let i = 0; i < adsdata.length; i++) { switch (adsdata[i].adtype) { case 'linear': showLinearAds({ ad: adsdata[i] }) break; case 'quickad': showQuickAds({ ad: adsdata[i] }) break; default: console.log(`Sorry, we are out of data`); } } } } async function showLinearAds({ ad }) { console.log('Showing linear ad'); let adhtmlString = `<div class="linear-ad"> <a class="linear-ad-link" href="${ad.link}" rel="noopener ugc nofollow sponsored"> <div class="linear-content"> <div class="linear-ad-title">${ad.title}</div> <div class="linear-ad-text">${ad.description}</div> </div> <div class="linear-image" style="background-image:url(https://newsandstory.com/tempImage/14061411272720213270.jpg)"></div> <div class="linear-ad-ad"><div class="linear-ad-div">AD</div></div> </a> </div>`; let contentEditor = document.getElementById("editordiv"); const parser = new DOMParser(); let adhtml = parser.parseFromString(adhtmlString, "text/html").body.firstChild; console.log(adhtml); console.log(contentEditor.firstChild); contentEditor.firstChild.after(adhtml); } async function showQuickAds({ ad }) { console.log('Showing Quick ad'); let adhtmlString = ` <div class="quickad-page"> <div class="quickad-head"><span class="quickad-adtext">Ad</span></div> <a class="quickad-link" href="https://core.newsandstory.com/redirect/?url=${ad.link}" target="_blank" rel="noopener ugc nofollow sponsored"> <div class="quickad-body"> <div class="quickad-item"> <div class="quickad-title">${ad.title}</div> <div class="quickad-main"> <div class="quickad-content">${ad.description}</div> <div class="quickad-imagewr"> <div class="quickad-imageUploadBanner" style="background-image:url(https://core.newsandstory.com/ads-images/${ad.photo}.jpg"></div> </div> </div> </div> </div> </a> </div>`; let contentEditor = document.getElementById("editordiv"); const parser = new DOMParser(); let adhtml = parser.parseFromString(adhtmlString, "text/html").body.firstChild; console.log(adhtml); console.log(contentEditor.firstChild); contentEditor.firstChild.after(adhtml); } async function subscribe() { document.getElementsByClassName('subscribe_submitbtn')[0].innerHTML = "Subscribing..." axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*'; var result = await axios.post("https://core.newsandstory.com/subscribe", { email: document.getElementsByClassName('subscribe_iemail')[0].value }) console.log(result); if (result.data.status == "success") { document.getElementsByClassName('subscribe_submitbtn')[0].innerHTML = "Subscribed"; } } </script> </html>