HTML

HTML or Hyper Text Markup Language is a standard markup language used to create web pages. It defines how a web page should be displayed to the user. When a user searches for something, the next page the user should view will be received in form of an HTML document. The web page creation is done by incorporating JavaScript and CSS( Cascading Style Sheet). JavaScript and CSS help in automating the execution and presentation of the webpages respectively. HTML elements are the basic building blocks of an HTML document. They contain tags that form a complete HTML document.

A standard HTML document looks like this:

Structure of a standard HTML document.
Structure of HTML document

What is an element in HTML?

Elements are the fundamental component of the HTML document. An HTML element tells the browser how to display the content on a web page. An HTML element is made of up two tags: an opening tag <> and a closing tag </> preceded by a slash ( / ) character. These tags define some attributes of the text or multimedia written in HTML documents. Some commonly used HTML elements are:

  • <HTML>.....</HTML> - An HTML document begins with <HTML>opening tag and ends with</HTML> closing tag. It is a container tag. All other HTML elements and tags are contained inside this element.
  • <HEAD>.....</HEAD> - It is contained inside HTML tag. This element gives a heading to the web page.
  • <TITLE>..... </TITLE> - It is contained inside <HEAD></HEAD> tag. It is an optional tag that provides the title to the web page.
  • <BODY>....</BODY> - All the text and multimedia visible on the web page are written inside the body element.

What is a tag in HTML?

HTML tags represent, how the data should be displayed on the web page. A tag is always enclosed in angular brackets. There is an opening tag and a closing tag. The opening tag is written as <...> and the closing tag contains a preceding slash </..>. The tags are important in HTML so that the browser can differentiate the normal text and HTML text.

Example of opening tag:

  1. <div> - opening division tag
  2. <p> - opening paragraph tag

Example of closing tag:

  1. </div> - closing division tag
  2. </p> - closing paragraph tag

Element vs Tags

  • Tag is the basic unit of an HTML document.
  • Element includes an opening tag, closing tag and some content in between these tags.
  • A paragraph element can be written as : <p> This is a paragraph </p>.
  • In above example, there is two tags. one opening tag- <p> and one closing tag- </p>.

Types of Tags

The two main types of tags are described below:

  1. Container Tags
  2. Empty Tags

Container Tags: Most HTML elements have a start tag and an end tag that indicate where the element begins and where it ends. These are called container tags.

Syntax- <Tagname>......</Tagname>

Example:

1.<p>......</p>      Paragraph tag allows you to write a paragraph in web page.

2. <a>.......</a>       An anchor tag is an important tag used to make the hyperlink that helps navigate

from one page to another. It uses the HREF attribute to provide the name of the link.

3. <font>.....</font>     This HTML tag is used to change the color, size of the content of the web page.

4. <I>............</I>  This is used to provide the italic style on the content. Any content of the web page that comes under this becomes italic.

Empty tags: There are some tags that do not contain any content inside them. These tags are called empty tags and only have a start tag since they dont have any content.

Syntax= <Tagname>

Example:

  1. <image> This tag can be used without a closing tag. Its attributes are specified in the opening tag.
  2. <hr> Horizontal rule provides straight line on the page.
  3. <br> Break tag works as enter key on the keyboard. It accommodates a new line in the web page.

Attributes of a tag

The general form of an HTML element is <tag attribute1 ="value1" attribute2 ="value2"> CONTENT </tag>. Attributes provide property to various tags. They are specified in the start tag and usually come in name-value pairs like attribute name="value." Attributes allow the user to customize the document as per the needs. If they are not mentioned by the user, then default values are used in each case automatically.

Syntax - <tag attribute1 ="value1" attribute2 ="value2"> CONTENT </tag>

Common Mistakes

Although HTML is a web designing language by itself, it is not a full-fledged language without the scripting and designing tools. HTML defines the structure and contents of a web page – where things go, how they are laid out, and what’s on the page, but it also uses CSS (Cascading Style Sheets). CSS documents also called stylesheets, define the styling/presentation of a web page and its HTML elements. HTML and CSS go hand in hand.

  • CSS(Cascading Style Sheets)
  • DHTML
  • JavaScript

Context and Applications

This topic is significant in the professional exams for both graduate and postgraduate courses, especially for:

  • Bachelor of Engineering
  • Bachelor of Computer Application
  • Bachelor of Science (CS)
  • Master of Computer Application

Practice Problems

Q1. ___________ are the basic building blocks of an HTML document.

  1. HTML attributes
  2. HTML tags
  3. HTML elements
  4. HTML CSS

Correct Answer: c) HTML elements

Explanation: The basic building blocks of HTML are HTML elements with tags and content.

Q2. An element without an end tag is called _________.

  1. incomplete tag
  2. container tag
  3. empty tag
  4. open element

Correct Answer: c) empty tag

Explanation: An HTML element without an end tag is an empty tag.

Q3. How many headings are there in <H1></H1> HTML tags?

  1. 4
  2. 3
  3. 7
  4. 6

Correct Answer: d) 6

Explanation: There are six heading tags in HTML, that are <h1> to <h6>, where the size decreases from <h1> to <h6>

Q4. While writing a paragraph, which of the following HTML tags are used?

  1. <p></p>
  2. <a></a>
  3. <b></b>
  4. <hr></hr>

Correct Answer: a) <p></p>

Explanation: The paragraph tag in HTML is written as <p>...</p>

Q5. Which attribute is used with HTML anchor tag<a>?

  1. paragraph
  2. href
  3. src
  4. value

Correct Answer: b) href

Explanation: The href attribute with <a> tag in HTML is used for giving reference links.

Want more help with your computer science homework?

We've got you covered with step-by-step solutions to millions of textbook problems, subject matter experts on standby 24/7 when you're stumped, and more.
Check out a sample computer science Q&A solution here!

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.

Search. Solve. Succeed!

Study smarter access to millions of step-by step textbook solutions, our Q&A library, and AI powered Math Solver. Plus, you get 30 questions to ask an expert each month.

Tagged in
EngineeringComputer Science

Web Development

Fundamentals of Web Development

Elements and Tags

Elements and Tags Homework Questions from Fellow Students

Browse our recently answered Elements and Tags homework questions.

Search. Solve. Succeed!

Study smarter access to millions of step-by step textbook solutions, our Q&A library, and AI powered Math Solver. Plus, you get 30 questions to ask an expert each month.

Tagged in
EngineeringComputer Science

Web Development

Fundamentals of Web Development

Elements and Tags