Page Title

How to Open HTML File From a Terminal?

Html file is a combination of symbols and text which displays the content of the web page. These files have .html extensions. In Linux, various methods exist to open Html files using the terminal or a graphical user interface. In this post, you will learn how to open Html files using the terminal in Linux. The content of the post is:

Method 1: Open HTML File in Browser

In Linux, you can open any Html file in your browser. There are two ways available for opening any Html file through the terminal. Let’s discuss these two functions one by one.

Using open Command

The “open” is a built-in utility to open any files or directories in Linux. The syntax to open any file using the “open” command is given below:

Syntax:

Write the “open” keyword and then type your Html file name.

Let’s move and check how it works. We have an index.html file in our home directory, which can be seen below:

Let’s open it in the browser using the “open command”.

To open any Html file using the “open” command is obtained as follows:

After executing the above command, it will automatically open the Html in your browser:

The index.html file is opened in the Firefox browser.

Using a Browser

You can open any Html file using a browser as well, and for that, you need to follow the below-mentioned syntax:

Type any browser name and then type your Html file name.

To open any Html file using the browser name, execute the following command in the terminal:

Once the above command is executed, the file will be opened in the browser. In our scenario, we have opened it in the chromium browser as shown in the below image:

The index.html file has been opened in the chromium browser.

Note: You can also use the bash script to open Html files in the browser. Just type in the bash script file and save it:

Once you save it, run the bash script file in the terminal:

The execution of the above command will give you the same output.

Let’s move towards method 2 to open Html files.

Method 2: Open HTML File Using lynx

Another method that can be used to open an Html file is using the “lynx”. “lynx” is a terminal-based web browser that prints the output of the file as plain text in the terminal. In simple words, it’s a non-graphical web browser that shows the web pages on the terminal. It is not pre-installed in Linux distributions; user can install it manually by executing the below command:

Читайте также:  Php backup all files

For Ubuntu/Debian:

For Fedora/CentOS/RHEL:

The syntax for using the “lynx” is shown below:

Syntax:

Type the “lynx” keyword, “options” for different modes and then file name.

To open an HTML file using “lynx”, use the “dump” option. “dump” option represents the standard output (stdout). Run the following command to see the results:

The content of the Html has been displayed as plain text.

Note: lynx will only print the Html content of the file. However, if you put any javascript content in an Html file, the javascript content will not be printed.

Using lynx, users can also open the Html file in its editor. To do so, use the lynx without option:

Once you type the command, press Enter:

An Html file is opened in the lynx text editor.

These are the possible methods to open an Html file using the terminal.

Bonus Tip: How to Edit the Content of the HTML File?

There are different commands available to open and edit the files in the text editor, such as pico, nano, vi, and much more. In our case, we are using the “nano” editor to open the Html file. The syntax for the nano editor command is shown below:

Syntax:

Write the “nano” keyword and then type the file name.

To open any Html file using the “nano” command is obtained as follows:

Once you execute the above command, it will open the Html file in the nano text editor from where you can edit the content of that HTML file.

Conclusion

To open any HTML file using the terminal, there are three methods. The first method is to open an HTML file in the browser using the “open” command or use any browser name along with the file name. The second method is to open an HTML file in text editors such as nano, while the third is to open an HTML file using lynx. This post has demonstrated all the possible ways to open an HTML file through a terminal in Linux.

Источник

How to Edit HTML Files

This article was co-authored by wikiHow staff writer, Travis Boylls. Travis Boylls is a Technology Writer and Editor for wikiHow. Travis has experience writing technology-related articles, providing software customer service, and in graphic design. He specializes in Windows, macOS, Android, iOS, and Linux platforms. He studied graphic design at Pikes Peak Community College.

This article has been viewed 133,093 times.

If you prefer to code websites by hand, you can edit HTML files in a basic text editor like Notepad (Windows) or TextEdit (macOS). If you would rather be able to move elements around on the screen and see live previews, you can use a WYSIWYG (What You See Is What You Get) editor like Dreamweaver or Kompozer. This wikiHow teaches you how to open and edit an HTML file in a standard or visual editing app.

Using a Notepad on Windows

Image titled Edit HTML Files Step 1

Windows Start

. It’s the button that has a Windows logo in the task bar. By default, it’s in the lower-left corner. This displays the Start menu

Читайте также:  Html form sends to email

Image titled Edit HTML Files Step 2

Image titled Edit HTML Files Step 3

Image titled Edit HTML Files Step 4

Click File . It’s at the top of the menu bar in Notepad. This displays a drop-down menu. This displays a file browser you can use to open files in Notepad.

Image titled Edit HTML Files Step 5

Image titled Edit HTML Files Step 6

Select «All files» in the file type drop-down menu. Click the drop-down that says «Text Documents (.txt)» and select «All files» in the drop-down menu. This displays all document types (including HTML files) in the file browser.

Image titled Edit HTML Files Step 7

Image titled Edit HTML Files Step 8

Edit the HTML code. In order to edit HTML in Notepad, you’ll need to learn HTML so that you can edit it by hand. Common elements you can edit include the following.

  • : This goes at the top of the HTML document. This tells the web browser that this is an HTML document.
  • : These tags go at the top and bottom of the HTML document. This indicates where the HTML code starts and stops.
  • : These tags go at the top of the HTML document. They indicate where the head of the HTML document starts and stops. The head of the HTML document contains information that is not seen on the web page. This includes the page title, metadata, and CSS
  • : These tags indicate the title the page. The title goes in the head of the HTML document. Type the title of the page in between these two tags.
  • : These tags indicate where the body of the HTML document starts and stops. The body is where all the web page content is written. The body comes after the head in the HTML document.
  • Headline Text

    : These tags create headline tags. The text in between the «

    » and «

    » tags appears as a large bold text. Text goes in the body of the HTML document.

  • Paragraph Text

    : These tags are used to create paragraph text in an HTML document. The text that goes in between «

    » and «

    » appears as normal sized text. Text goes in the body of the HTML document.

  • Bold Text : These tags are used to create bold text. The text that goes in between «» and «» appears as bold text.
  • Italic Text : These tags are used to create italic text. The text that goes in between «» and «» appears as itallic text.
  • Link text : This tag is used to link to another website. Copy the web address you want to link to and paste it where it says «URL» (in between the quotation marks). The the text for the link where it says «Link text» (no quotation marks needed).
  • : This tag is used to post an image using HTML. Replace teh text that says «image URL» with the web address of the image.

Image titled Edit HTML Files Step 9

Image titled Edit HTML Files Step 10

  • To save the file as it’s existing name and file type, just click Save in the drop-down menu below «File».

Image titled Edit HTML Files Step 11

Image titled Edit HTML Files Step 12

Image titled Edit HTML Files Step 13

Type .html at the end of the file. After you type a name for the file in the «File Name» box, add the extension «.html» at the end of the file name. Without this extension, it will save the file as a .txt file, instead of an HTML file.

Image titled Edit HTML Files Step 14

Using TextEdit on Mac

Image titled Edit HTML Files Step 15

Mac Spotlight

Image titled Edit HTML Files Step 16

Image titled Edit HTML Files Step 17

Click TextEdit.app . It’s at the top of the search results. It’s next to an icon that resembles a sheet of paper and a pen.

Image titled Edit HTML Files Step 18

Image titled Edit HTML Files Step 19

Image titled Edit HTML Files Step 20

Click an HTML file and click Open . HTML files have an extension that says «.html» after the file name. Use the file browser to navigate to an HTML file and click it to select it. Then click Open to open the HTML file in TextEdit.

Image titled Edit HTML Files Step 21

Edit the HTML code. You can use TextEdit to edit HTML code on make. You need to learn HTML so that you can edit it by hand. Common elements you can edit include the following.

  • : This goes at the top of the HTML document. This tells the web browser that this is an HTML document.
  • : These tags go at the top and bottom of the HTML document. This indicates where the HTML code starts and stops.
  • : These tags go at the top of the HTML document. They indicate where the head of the HTML document starts and stops. The head of the HTML document contains information that is not seen on the web page. This includes the page title, metadata, and CSS
  • : These tags indicate the title the page. The title goes in the head of the HTML document. Type the title of the page in between these two tags.
  • : These tags indicate where the body of the HTML document starts and stops. The body is where all the web page content is written. The body comes after the head in the HTML document.
  • Headline Text

    : These tags create headline tags. The text in between the «

    » and «

    » tags appears as a large bold text. Text goes in the body of the HTML document.

  • Paragraph Text

    : These tags are used to create paragraph text in an HTML document. The text that goes in between «

    » and «

    » appears as normal sized text. Text goes in the body of the HTML document.

  • Bold Text : These tags are used to create bold text. The text that goes in between «» and «» appears as bold text.
  • Italic Text : These tags are used to create italic text. The text that goes in between «» and «» appears as itallic text.
  • Link text : This tag is used to link to another website. Copy the web address you want to link to and paste it where it says «URL» (in between the quotation marks). The the text for the link where it says «Link text» (no quotation marks needed).
  • : This tag is used to post an image using HTML. Replace teh text that says «image URL» with the web address of the image.

Источник

Оцените статью