Open In App

How To Execute HTML Program?

Last Updated : 25 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

HTML (HyperText Markup Language) is the standard language used to create web pages. Executing an HTML program is the process of rendering the code in the browser to display a web page.

There are several approaches to running HTML code each suitable for the different environments and use cases. we will explore all possible methods to execute an HTML program.

These are the following approaches to execute the HTML program:

Using Local HTML File

A simple and common method is to create an HTML file locally on the computer and open it in a browser.

Steps:

  • Open a text editor (Notepad, VSCode, Sublime Text).
  • Write your HTML code.
  • Save the file with a .html extension.
  • Open the file by double-clicking it or right-click and choose "Open with" -> Browser.

Example: This example shows the execution of HTML by running the given code in the online code editor.

HTML
<!-- index.html -->

<!DOCTYPE html>
<html>

<head>
    <title>My First HTML Page</title>
</head>

<body>
    <h1>Hello, World!</h1>
</body>

</html>

Output :

8

Using Online Code Editors

We can use online editors like CodePen, JSFiddle or onecompiler to run HTML code without the setting up a local environment.

Steps:

  • Open an online code editor.
  • Write your HTML code in the editor.
  • The result is usually displayed in real-time as we type.

Example: This example shows the execution of HTML by pasting the given code in the online code editor.

HTML
<!-- index.html -->

<!DOCTYPE html>
<html>

<head>
    <title>My First HTML Page</title>
</head>

<body>
    <h1>Hi, GeeksforGeeks</h1>
</body>

</html>

Output:

8

Conclusion

We explored various approaches to the execute HTML code including the local files, online editors, code editors and browser developer tools. Each approach has its own use cases and we can choose the one that best fits your requirements.


Next Article
Article Tags :

Similar Reads