- What indicates the beginning and end of an HTML document?
- What indicates the beginning and end of an HTML document?
- What is the first part of an HTML document?
- What is HTML and its basic structure?
- When did head and body become part of HTML?
- What are the HTML elements inside the body?
- HTML for Beginners
- HTML Structure
- Elements
- Tags
- Kinds of Elements
- Attributes
- Nesting
- Common HTML Tags
- Links
- Comments
- Tables
- Trivia time!
- Conclusion
- HTML Elements
- HTML Elements
- Nested HTML Elements
- Example
- My First Heading
- Example Explained
- My First Heading
- My First Heading
- and an end tag
- My First Heading
- Never Skip the End Tag
- Example
- Empty HTML Elements
- Example
- HTML is Not Case Sensitive
- HTML Tag Reference
- HTML Basic Examples
- HTML Documents
- Example
- My First Heading
- The Declaration
- HTML Headings
- Example
- This is heading 1
- This is heading 2
- This is heading 3
- HTML Paragraphs
- Example
- HTML Links
- Example
- HTML Images
- Example
- How to View HTML Source
- View HTML Source Code:
- Inspect an HTML Element:
What indicates the beginning and end of an HTML document?
What indicates the beginning and end of an HTML document?
The element is the root element and it defines the whole HTML document. It has a start tag and an end tag .
What are the parts of an HTML document?
An HTML 4 document is composed of three parts:
- a line containing HTML version information,
- a declarative header section (delimited by the HEAD element),
- a body, which contains the document’s actual content. The body may be implemented by the BODY element or the FRAMESET element.
Can you have a section within a section HTML?
Sectioning elements can be nested inside one another as many times as is needed based on the content. The header and footer in a sectioning element can also contain sectioning elements.
What is the first part of an HTML document?
The first tag in any HTML file is the tag. This tells web browsers that the document is an HTML file. The second tag is a tag. Information between the HEAD tags doesn’t appear in the browser window, but is still important.
What are the symbols which begin and end a tag?
HTML tags begin with symbol < and end with >;…..
What are two main sections of HTML?
The two main parts of an HTML document are the head and the body. Each section contains specific information. The head section contains information that is useful to the Web browser and search engines but is not visible to the reader. The body section contains the information that you want the visitor to see.
What is HTML and its basic structure?
HTML is the standard markup language for creating Web pages. HTML describes the structure of a Web page. HTML consists of a series of elements. HTML elements tell the browser how to display the content. HTML elements label pieces of content such as “this is a heading”, “this is a paragraph”, “this is a link”, etc.
What is a section tag in HTML?
Section tag defines the section of documents such as chapters, headers, footers or any other sections. The section tag divides the content into section and subsections. The section tag is used when requirements of two headers or footers or any other section of documents needed.
What are the two main sections of an HTML document?
An HTML Document is mainly divided into two parts:
- HEAD: This contains the information about the HTML document. For Example, Title of the page, version of HTML, Meta Data etc.
- BODY: This contains everything you want to display on the Web Page.
When did head and body become part of HTML?
The html, head, and body elements have been part of the HTML specification since the mid 1990s, and up until a few years ago they were the primary elements used to give structure to HTML documents.
What are the sectioning elements in HTML5?
The sectioning elements in HTML5 are , , , and . is also kind of a sectioning element since all content lying inside of it is part of the default document section. Here is a brief explanation of each sectioning element and how they are used:
Which is the first element to appear in HTML?
An opening tag should appear first and a closing tag should appear at the bottom of the document. Every other bit of HTML should appear between those two tags. The head element is the first element to appear after the opening html tag.
What are the HTML elements inside the body?
Inside the element is two other HTML elements: and . The element defines a heading. It has a start tag and an end tag . The element content is: My First Heading. The element defines a paragraph. It has a start tag and an end tag . The element content is: My first paragraph.
HTML for Beginners
This article will teach you the basics of HTML. I also created a 45-minute video course on the freeCodeCamp.org YouTube channel that teaches you HTML in the context of creating an actual web page.
If you are just learning HTML, I recommend both reading this article and watching the video course.
HTML stands for Hyper Text Markup Language. Every website on the internet uses HTML & CSS. Most also use JavaScript.
In a website, HTML is the structure, CSS is the style, and JavaScript is the functionality.
Here is a great interactive diagram from codeanalagies.com. Move the slider back and forth.
You can actually see the HTML that makes up any element on a webpage by right-clicking an element and then selecting «Inspect».
HTML Structure
Here is the HTML that makes up a very basic webpage:
This is an amazing website!
Let’s break things down even more.
Elements
HTML is made up of HTML elements. An element is an individual component of HTML.
Here is an HTML element from the code above:
This is an amazing website!
Tags
HTML tags mark the beginning and end of an element (and are considered part of the element). Tags are containers. They tell you something about the content between the opening & closing tags.
In the element above, the tags are
(opening tag) and
(closing tag). You will notice that the closing tag has a / . This particular tag is a p aragraph tag. It specifies a paragraph in the HTML document. The words between the opening and closing tags are a paragraph.
Kinds of Elements
Elements can be either container elements (they hold content) or stand-alone elements, sometimes called self-closing elements.
Paragraph elements are containers:
Hi, I contain content
Image elements are stand-alone:
Notice in the stand-alone img element, there is no closing tag but there is a / before the final angle bracket.
Attributes
Attributes provide additional information about HTML elements. Attribute tags include class , id , style , lang , and src (source).
Here is an example of an HTML element with the attribute tag id :
This is an amazing website!
Some things to note about attributes:
- Attributes are positioned inside the opening tag, before the right bracket.
- Attributes are paired with values (in this example, the value is info ).
- Key / value pairs are an important concept in programming.
- Attributes are selected from a pre-defined set of possible attributes depending on the element.
- Values are assigned to attributes and they must be contained inside quotation marks.
Here is another example of an element with at attribute:
Nesting
HTML elements ‘nest’ inside of one another. The element that opens first closes last.
When nesting elements, spaces and tabs are often used to show the level of nesting. However, the spacing is not required and is only used to make HTML easier to read for humans.
Here is an example of some HTML with a few levels of nesting elements:
Common HTML Tags
Here are some common tags that are in almost all HTML documents.
doctype : This is the first element on every HTML page. It tells the browser to expect HTML and what version to use. For the newest version of HTML, the element should look like this:
html : After the doctype, all page content must be contained in the tags.
head : This element contains the page title and metadata.
body : This element contains all the visible content in a page.
title : This optional element is the name of your page. It is always nested in the head tag.
div : This tag is one of the most used tags. It is used to create a basic container of other HTML or content.
p : A paragraph or section of body copy.
h1 — h6 : These designate different levels of headings or titles.
ol : Creates an ordered (numbered) list.
ul : Creates an unordered list.
Links
Anchor elements ( ) are used to link to other sites on the web or within your project.
This element links to another website:
This element links to another page of your website:
The element is a different type of link. Unlike the anchor element, it specifies relationships between the current document and an external resource.
It is often used to link a CSS file with an HTML file so that the external CSS file is used to style the HTML.
Comments
Like any other good coding language, HTML offers comments. They operate like comments in any other language. They are ignored by the browser engine.
Tables
Tables are a way to represent complex information in a grid format. They are made of rows and columns.
Tables are compound elements (similar to lists) they are made up of several elements.
th : Table header cell (optional).
Here is an example of a table. First you will see the HTML. Then you will see how the HTML displays.
Firstname Lastname Favorite Animal Beau Carnes cow Quincy Larson dog
Trivia time!
2. What is wrong with this code?
The best site ever!! Check out this great content.
3. What is wrong with this code?
Conclusion
You’ve now learned the basics of HTML syntax.
Next you should watch this HTML crash course I created that teaches HTML in the context of building a simple web page.
After you learn HTML, you should learn CSS and JavaScript. I have also created courses on those topics. You can watch them next:
HTML Elements
An HTML element is defined by a start tag, some content, and an end tag.
HTML Elements
The HTML element is everything from the start tag to the end tag:
Examples of some HTML elements:
Note: Some HTML elements have no content (like the
element). These elements are called empty elements. Empty elements do not have an end tag!
Nested HTML Elements
HTML elements can be nested (this means that elements can contain other elements).
All HTML documents consist of nested HTML elements.
The following example contains four HTML elements ( , , and
):
Example
My First Heading
My first paragraph.
Example Explained
The element is the root element and it defines the whole HTML document.
It has a start tag and an end tag .
Then, inside the element there is a element:
My First Heading
My first paragraph.
The element defines the document’s body.
It has a start tag
and an end tag .Then, inside the element there are two other elements: and
:
My First Heading
My first paragraph.
The element defines a heading.
It has a start tag
and an end tag
:
My First Heading
The
element defines a paragraph.
It has a start tag
and an end tag
:
Never Skip the End Tag
Some HTML elements will display correctly, even if you forget the end tag:
Example
This is a paragraph
This is a paragraph
However, never rely on this! Unexpected results and errors may occur if you forget the end tag!
Empty HTML Elements
HTML elements with no content are called empty elements.
The
tag defines a line break, and is an empty element without a closing tag:
Example
This is a
paragraph with a line break.
HTML is Not Case Sensitive
HTML tags are not case sensitive: means the same as
.
The HTML standard does not require lowercase tags, but W3C recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML.
At W3Schools we always use lowercase tag names.
HTML Tag Reference
W3Schools’ tag reference contains additional information about these tags and their attributes.
Tag | Description |
---|---|
Defines the root of an HTML document | |
Defines the document’s body | |
to | Defines HTML headings |
For a complete list of all available HTML tags, visit our HTML Tag Reference.
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.
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
HTML Paragraphs
HTML paragraphs are defined with the
tag:
Example
This is a paragraph.
This is another paragraph.
HTML Links
HTML links are defined with the tag:
Example
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 tag.
The source file ( src ), alternative text ( alt ), width , and height are provided as attributes:
Example
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.