SHARE
Facebook X Pinterest WhatsApp

New on HTMLGoodies: Test Your HTML

Written By
thumbnail Scott Clark
Scott Clark
Jul 21, 2010

We’ve added a new feature to HTMLGoodies that enables you, the reader, to actually test your HTML live on our site. Where applicable, we’ll add a “test the code” form on a tutorial page. If you’d like to test out the HTML, CSS or JavaScript that is being discussed, simply copy and paste it into the form, and press the “view” button. A new window or tab (depending on how you have your browser configured) will open, showing the results of the code you just entered.

How Does It Work?

This is what the Test Your HTML box will look like, except that we have already entered some code, in this case, a bit of JavaScript that writes out your IP address when the window is opened, and a couple lines of CSS that make use of the Google Font API.





And here’s how it will normally appear on the page:

Test Out Your Code




Can I See the Code That Does the Work?

The JavaScript behind this little tool is fairly simple. It just takes the text that you enter into the form field, and writes it to the new document that is opened. Your web browser does the rest. Here’s the actual JavaScript function:

function displayHTML(form) {
  var inf = form.htmlArea.value;
  win = window.open(“, “, ‘popup’, ‘toolbar = no, status = no’);
  win.document.write(“” + inf + “”);
}

Note that since your web browser actually interprets the HTML code you have entered, the way it will behave will depend on the features that are supported by your browser. Have fun!

Recommended for you...

Best JavaScript Frameworks & Libraries for Building Web Dashboards
Rob Gravelle
Jul 29, 2021
Google Web Vitals for Beginners
Diogo Souza
May 4, 2021
Web Site Maintainability
Vince Barnes
Jan 10, 2021
Getting Started with Grunt.js
Diogo Souza
Oct 8, 2018
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.