How do i get the html code for a document?

Updated: 08/31/2020 by

How do i get the html code for a document?

Microsoft Word supports the ability to save any document as a web page. However, there is no way to view the source code in the most recent versions of Microsoft Word.

Microsoft Word 2007, 2010, and later

As mentioned above, there is no way to view the source code of an HTML document in the most recent versions of Microsoft Word. However, if you open the document in any browser, you can view the source using the browser.

  • How to view the HTML source code of a web page.

While viewing the source code is possible in a browser, to make code changes, we suggest using a text editor or an HTML editor. Not only is it easier to create and modify an HTML file, your source code looks more clean and is less likely to cause incompatibility issues in different browsers.

If you want to use Microsoft Word because of its WYSIWYG interface, realize that many of the more profession HTML editors also have a WYSIWYG interface. For example, Microsoft Expression Web is now free and has an easy to use interface.

Microsoft Word 2003

Microsoft Word 2003 did support the ability to view the HTML source code by clicking View and select HTML source.

HTML Basic Examples


In this chapter we will show some basic HTML examples.

Don't worry if we use tags you have not learned about yet.


HTML Documents

All HTML documents must start with a document type declaration: .

The HTML document itself begins with and ends with .

The visible part of the HTML document is between and .

Example



My First Heading


My first paragraph.


Try it Yourself »


The Declaration

The declaration represents the document type, and helps browsers to display web pages correctly.

It must only appear once, at the top of the page (before any HTML tags).

The declaration is not case sensitive.

The declaration for HTML5 is:


HTML Headings

HTML headings are defined with the

to
tags.

defines the most important heading.
defines the least important heading: 

Example

This is heading 1


This is heading 2


This is heading 3

Try it Yourself »



HTML Paragraphs

HTML paragraphs are defined with the

tag:

Example

This is a paragraph.


This is another paragraph.

Try it Yourself »


HTML Links

HTML links are defined with the tag:

The link's destination is specified in the href attribute. 

Attributes are used to provide additional information about HTML elements.

You will learn more about attributes in a later chapter.


HTML Images

HTML images are defined with the

How do i get the html code for a document?

Try it Yourself »


How to View HTML Source

Have you ever seen a Web page and wondered "Hey! How did they do that?"

View HTML Source Code:

Right-click in an HTML page and select "View Page Source" (in Chrome) or "View Source" (in Edge), or similar in other browsers. This will open a window containing the HTML source code of the page.

Inspect an HTML Element:

Right-click on an element (or a blank area), and choose "Inspect" or "Inspect Element" to see what elements are made up of (you will see both the HTML and the CSS). You can also edit the HTML or CSS on-the-fly in the Elements or Styles panel that opens.



This tutorial will introduce you to a basic HTML document and teach you how to view the source code of an HTML document in a browser.

HTML is used to mark up a document with instructions that tell a browser how to display and interpret the document’s content. For example, HTML can tell the browser which text content should be interpreted as a heading and which text content should be interpreted as paragraphs. HTML is also used to add images and assign links to text and images. These instructions are communicated through HTML tags, which are written like this: . Many, though not all tags, use an opening tag and closing tag to wrap around the content that they are used to modify.

To get a sense of how these tags are used, let’s inspect a snippet of HTML code. The HTML code below shows how HTML tags are used to structure text and add links and images. Don’t worry if you don’t understand the tags immediately- we’ll study those in the next tutorial.

<h2>Sammy's Sample HTMLh2>

<p>This code is an example of how HTML is written.p>

<p>It uses HTML tags to structure the text.p>

<p>It uses HTML to add a <a href="digitalocean.com/community">linka>.p>

<p>And it also uses HTML to add an image:p>

<img src="https://html.sammy-codes.com/images/small-profile.jpeg"/>

This HTML code is rendered in the browser as follows:

How do i get the html code for a document?

You should now have an understanding of how the HTML example code is rendered in a browser. Next, we will learn how to view the source code of any webpage using a browser tool.

Viewing the Source Code of a Webpage

Nearly every webpage you come across uses HTML to structure and display HTML pages. You can inspect the source code of any webpage by using a web browser like Firefox or Chrome. On Firefox, navigate to the “Tools” menu item in the top menu and click on “Web Developer/Page Source” like so:

How do i get the html code for a document?

On Firefox, you can also use the keyboard shortcut Command-U to view the source code of a webpage.

On Chrome, the process is very similar. Navigate to the top menu item “View” and click on “Developer/View Source.” You can also use the keyboard shortcut Option-Command-U.

Try inspecting the source code of the demo website that we will build in this tutorial series. You should receive a page with many more HTML tags than our example above. Don’t be alarmed if it seems overwhelming. By the end of this tutorial series, you should have a better understanding of how to interpret HTML source code and how to use HTML to build and customize your own websites.

Note: As mentioned above, you can inspect the source code of any webpage using tools from the Firefox or Chrome web browser. Try inspecting the code of a few of your favorite websites to get a sense of the underlying code that structures web documents. Though the source code of these sites will likely contain more languages than HTML, learning HTML first will help prepare you to learn additional languages and frameworks for creating websites later on if you wish.

You should now have a general understanding of the format of an HTML document and know how to inspect HTML source code using a browser tool. To better understand how HTML works, let’s inspect its key components. In the next tutorial, we will learn more about HTML elements, the building blocks that are used to create HTML documents.

How do I get the HTML code from a file?

Fire up Chrome and jump to the webpage you want to view the HTML source code. Right-click the page and click on “View Page Source,” or press Ctrl + U, to see the page's source in a new tab. A new tab opens along with all the HTML for the webpage, completely expanded and unformatted.

How do I get HTML code from a Word document?

Using MS Words built-in save as HTML option Go to the file menu. Select Save as. In the drop-down file type box select, Web Page, Filtered. Click Save.

How do I find my HTML code?

To view only the source code, press Ctrl + U on your computer's keyboard. Right-click a blank part of the web page and select View source from the pop-up menu that appears.

How do I make a document HTML?

HTML Editors.
Step 1: Open Notepad (PC) Windows 8 or later: ... .
Step 1: Open TextEdit (Mac) Open Finder > Applications > TextEdit. ... .
Step 2: Write Some HTML. Write or copy the following HTML code into Notepad: ... .
Step 3: Save the HTML Page. Save the file on your computer. ... .
Step 4: View the HTML Page in Your Browser..