Simple web page coding in html

There are the following different examples implemented for creating the simple HTML pages using the different basic tags:

Example 1: This example creates a simple page without any content, which helps in understanding how to use the Html, Head, and Body tag in the HTML page.

In the following example, we have not specified the title of the web page in the Head tag, so it will display the name of Html file as its title.

Test it Now

Output:

Simple web page coding in html

Example 2: This example creates a page which helps in understanding how to give a title to a web page.

Test it Now

Output:

Simple web page coding in html

Example 3: This example creates a web page which helps in understanding how to make the text bold, italic, and underline.

Test it Now

Output:

Simple web page coding in html

Example 4: This example creates a web page which helps in understanding how to use the

tag.

Test it Now

Output:

Simple web page coding in html

Example 5: This example creates a web page which helps in understanding how to define all header levels.

In HTML, there are 6 header levels from h2 to h6.

Test it Now

Output:

Simple web page coding in html

Example 6: This example creates a web page which helps in understanding how to align the text in center, and how to break a line.

Test it Now

Output:

Simple web page coding in html

Example 7: The following example describe how to link one page to another.

Test it Now

Output:

Simple web page coding in html

  • Previous
  • Overview: Getting started with the web
  • Next

HTML (HyperText Markup Language) is the code that is used to structure a web page and its content. For example, content could be structured within a set of paragraphs, a list of bulleted points, or using images and data tables. As the title suggests, this article will give you a basic understanding of HTML and its functions.

So what is HTML?

HTML is a markup language that defines the structure of your content. HTML consists of a series of elements, which you use to enclose, or wrap, different parts of the content to make it appear a certain way, or act a certain way. The enclosing tags can make a word or image hyperlink to somewhere else, can italicize words, can make the font bigger or smaller, and so on. For example, take the following line of content:

My cat is very grumpy

If we wanted the line to stand by itself, we could specify that it is a paragraph by enclosing it in paragraph tags:

<p>My cat is very grumpyp>

Anatomy of an HTML element

Let's explore this paragraph element a bit further.

Simple web page coding in html

The main parts of our element are as follows:

  1. The opening tag: This consists of the name of the element (in this case, p), wrapped in opening and closing angle brackets. This states where the element begins or starts to take effect — in this case where the paragraph begins.
  2. The closing tag: This is the same as the opening tag, except that it includes a forward slash before the element name. This states where the element ends — in this case where the paragraph ends. Failing to add a closing tag is one of the standard beginner errors and can lead to strange results.
  3. The content: This is the content of the element, which in this case, is just text.
  4. The element: The opening tag, the closing tag, and the content together comprise the element.

Elements can also have attributes that look like the following:

Simple web page coding in html

Attributes contain extra information about the element that you don't want to appear in the actual content. Here, class is the attribute name and editor-note is the attribute value. The class attribute allows you to give the element a non-unique identifier that can be used to target it (and any other elements with the same class value) with style information and other things.

An attribute should always have the following:

  1. A space between it and the element name (or the previous attribute, if the element already has one or more attributes).
  2. The attribute name followed by an equal sign.
  3. The attribute value wrapped by opening and closing quotation marks.

Note: Simple attribute values that don't contain ASCII whitespace (or any of the characters " ' ` = < >) can remain unquoted, but it is recommended that you quote all attribute values, as it makes the code more consistent and understandable.

Nesting elements

You can put elements inside other elements too — this is called nesting. If we wanted to state that our cat is very grumpy, we could wrap the word "very" in a element, which means that the word is to be strongly emphasized:

<p>My cat is <strong>verystrong> grumpy.p>

You do however need to make sure that your elements are properly nested. In the example above, we opened the

element first, then the element; therefore, we have to close the element first, then the

element. The following is incorrect:

<p>My cat is <strong>very grumpy.p>strong>

The elements have to open and close correctly so that they are clearly inside or outside one another. If they overlap as shown above, then your web browser will try to make the best guess at what you were trying to say, which can lead to unexpected results. So don't do it!

Empty elements

Some elements have no content and are called empty elements. Take the

Simple web page coding in html

The keywords for alt text are "descriptive text". The alt text you write should provide the reader with enough information to have a good idea of what the image conveys. In this example, our current text of "My test image" is no good at all. A much better alternative for our Firefox logo would be "The Firefox logo: a flaming fox surrounding the Earth."

Try coming up with some better alt text for your image now.

Marking up text

This section will cover some of the essential HTML elements you'll use for marking up the text.

Headings

Heading elements allow you to specify that certain parts of your content are headings — or subheadings. In the same way that a book has the main title, chapter titles, and subtitles, an HTML document can too. HTML contains 6 heading levels,

-

, although you'll commonly only use 3 to 4 at most:


<h2>My main titleh2>
<h2>My top level headingh2>
<h3>My subheadingh3>
<h4>My sub-subheadingh4>

Note: Anything in HTML between is an HTML comment. The browser ignores comments as it renders the code. In other words, they are not visible on the page - just in the code. HTML comments are a way for you to write helpful notes about your code or logic.

Now try adding a suitable title to your HTML page just above your

Simple web page coding in html

If you get stuck, you can always compare your work with our finished example code on GitHub.

Here, we have only really scratched the surface of HTML. To find out more, go to our Learning HTML topic.

  • Previous
  • Overview: Getting started with the web
  • Next

In this module

How can you create simple Web pages in HTML?

Follow the steps below to create your first web page with Notepad or TextEdit..
Step 1: Open Notepad (PC) Windows 8 or later: ... .
Step 1: Open TextEdit (Mac) Open Finder > Applications > TextEdit. ... .
Step 2: Write Some HTML. ... .
Step 3: Save the HTML Page. ... .
Step 4: View the HTML Page in Your Browser..

What is the HTML code for web page?

HTML (HyperText Markup Language) is the code that is used to structure a web page and its content. For example, content could be structured within a set of paragraphs, a list of bulleted points, or using images and data tables.

What is the simplest HTML page?

Example 1: This example creates a simple page without any content, which helps in understanding how to use the Html, Head, and Body tag in the HTML page. In the following example, we have not specified the title of the web page in the Head tag, so it will display the name of Html file as its title.