App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide How to Test HTML Code in a Browser?

How to Test HTML Code in a Browser?

By Neha Bharati, Community Contributor -

HTML is the backbone of all the web pages on the web. 

HTML is used to make the basic structure of a website and display the page’s desired UI. Since it is the foundation of any web page, it becomes vital to test HTML code in a normal browser along with cross-browser testing scenarios. The quickest way is to test it on the browser, so, let’s look at how this can be done and also how to test HTML code on real device-browser combinations.

Importance of Testing HTML Code in the Browser

One may wonder why it would be required to test code in the browser. To clarify, testing HTML code in a browser refers to checking minor changes in the code. For example, checking if CSS for cross browser compatibility is being appropriately applied or manipulating an element in HTML to check its behavior.

Dev tools allow developers to inspect the HTML code, check load times of assets, store data, and much more.

  • Using dev tools makes it very easy for developers to test small code changes and analyze the page’s behavior. 
  • It is worth noting that testing HTML code in a browser is a far cry from the traditional manual or automated tests done on any application. 
  • They are extensive tests done to test the functionality and reliability of an application, whereas dev tools help to test websites on a much smaller level.

Dev tools are available in every browser and have the same features all across. It would be even swell if there was a platform to perform cross-browser testing. BrowserStack is the industry-leading cloud infrastructure that allows users to test their applications across devices, browsers, and operating systems. It also has built-in Dev tools where users can test their HTML code on a real device in any browser for detecting any cross browser compatibility issues.

You can also perform a lighthouse test on your website using the dev tools, which gives your website an overall score in terms of performance, accessibility, SEO, etc. this is a benchmark for all the websites and is a very useful tool.

How to Test HTML Code in a Browser

Every browser has a handy feature where developers can test HTML code on the browser page. Let’s see how

  • Visit any website. On right-clicking anywhere on the page, one can inspect the page, by clicking on the inspect button.

Inspect Browser

  • Clicking on Inspect opens the browser dev tools where developers can see the entire HTML code and CSS used to develop the page in the “Elements” tab. 
  • On hovering over any element in the HTML code, the corresponding element gets highlighted on the page as seen below.

Inspect element in Browser-testing html code in a browser

  • Let’s say a developer wants to change the background color and test it on the browser. It can be done by accessing the CSS values as seen in the dev tools. 
  • Let’s change the background color of the “Get started free” button from blue to black. To do this, locate the element in the HTML code and change the color in the CSS.

Change Background color-testing html code in a browser

Button color

As seen above, the background has been changed in the CSS, and the button is now black.

This is a quick way for developers to visualize and test some simple page features if needed. It makes it very convenient for developers who would otherwise have to develop the features and then deploy them every time to see the most minute changes. 

With dev tools, it is so much quicker, easier, and accessible to test such features. If developers are satisfied with the changes, they can develop them and finally deploy them all at once. 

This is just one of many applications of dev tools. Developers can see the layout of the page, check the accessibility of the page, modify specific attributes and classes in the HTML, and many other features worth exploring in the dev tools.

Testing HTML Code using BrowserStack Live

BrowserStack Live allows cross browser testing across different devices, browsers, and operating systems. Devs, QAs, and testers can access 3000+ real devices to test on. Apart from this it also allows in-browser testing using dev tools that streamline your cross browser compatible website and HTML files. 

Let’s learn how to test HTML code on webpages using the dev tools in Browserstack Live.

  • Firstly, sign up for a new account or sign in if you have an existing account. 
  • Then type the website you want to test and click on “Start test”. The details of the website tested here are as follows: www.browserstack.com

Enter text in text box

Sign In Page

  • Once logged in, the user is redirected to the dashboard where they can select the device-browser-os combination they want to test on. BrowserStack also allows users to test for cross-browser compatibility.

testing html code in a browser on BrowserStack Live

  • The device information that is used for this test is as below.

          Device: One Plus 7T

          Browser: Google Chrome

          OS: Android

testing html code in a Real Mobile on BrowserStack Live

As seen in the side panel, there is an option called “DevTools”. 

It will be used to inspect the page and test the page on the browser. Now that the dev tools are open we will attempt to modify the background color of the “Get Started” button that you see in the picture below, from blue to black.

testing html code using DevTools on Mobile device

Like you would do it in a browser, let’s find the button in the elements tab and change the background color to black, as shown in the picture below. This is how we can modify the button color in the browser.

Update color

Let’s try to do the same on BrowserStack Live. The followed steps would be exactly the same and we can view the results below. 

Device: Desktop(1280×642)

Browser: Safari

OS: macOS(Big Sur)

Inspect element on BigSur

The edited parts are as seen above. Even Safari dev tools can be used to change the background color of the button. There are other browsers like Edge, Firefox, and Opera. With so many choices, users can quickly test for cross-browser compatibility.

Once you are done testing your code, you can either stop your session or choose another configuration.

Real Device testing

On clicking, “Stop Session” in the toolbar, you will be redirected to the dashboard to pick up and test another combination of cross-browser compatibility code HTML.

Live Dashboard

Summing it Up, 

  • This is one of many ways a user can use the browser dev tools and also test HTML code using BrowserStack Live. 
  • By leveraging the power of dev tools, developers can achieve so much in terms of quick debugging and testing their applications. 
  • Using dev tools, one can learn a lot about their website, like how web pages are put together for that perfect UI. 
  • A developer can see the entire source code just by using the inspect option. 
  • It gives developers an easier way to perform tasks on their website than from within your application.

Bear in mind that while you’re testing HTML code in a browser,  cross-browser testing is an absolute must, and it must be done on real device-browser-OS combinations for accurate results. Your team can start running tests on 30+ versions of the latest browsers across Windows and macOS with BrowserStack Live for Teams.

Get faster results without compromising on the accuracy and detect HTML and CSS errors before users do by testing software in real user conditions.

Use BrowserStack Live

Tags
Cross browser testing Website Testing

Featured Articles

Cross Browser Compatible Websites – 3 Easy Ways to Make

Browser Compatibility Check on WordPress Sites

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.