HTML 5 – 7 important questions answers

Q. Define the <Center> <HTML> <SUP>

<center> The <center> tag is a deprecated HTML element that is used to center its block-level or inline contents horizontally within its containing element.

It has been deprecated since HTML 4 in favor of the CSS text-align property, which can be applied to the <div> element or to an individual <p>.

Example:

HTML

<center>This text is centered.</center>

<html> The <html> tag is the root element of an HTML document. It contains all of the other elements in the document, including the <head> and <body> elements.

Example:

HTML

<!DOCTYPE html>
<html>
<head>
  <title>My Web Page</title>
</head>
<body>
  <h1>This is my web page.</h1>
</body>
</html>

Use code with caution. Learn morecontent_copy

<sup> The <sup> tag is used to define superscript text. Superscript text appears half a character above the normal line and is sometimes rendered in a smaller font.

Superscript text can be used for footnotes, like WWW.

Example:

HTML

<h1>H<sub>2</sub>O</h1>

Use code with caution. Learn morecontent_copy

This will render as:

H2O

Q. How to change font settings in Webpage?

There are two ways to change font settings in a webpage:

  1. Using HTML tags: HTML also provides a few tags that can be used to change font settings, such as <font>, <sup>, and <sub>. However, these tags are deprecated in HTML 5 and should be avoided if possible.For example, the following HTML code will change the font of the text to Arial and the font size to 16 pixels:HTML<font face="Arial" size="4">This text is in Arial font, size 16.</font>

If you need to change font settings for a specific element on the page, such as a paragraph or heading, you can use the style attribute to apply CSS to that element. For example, the following HTML code will change the font of the first paragraph on the page to Arial and the font size to 16 pixels:

HTML

<p style="font-family: Arial, sans-serif; font-size: 16px;">This is the first paragraph.</p>
  1. Using CSS: CSS is the preferred way to change font settings, as it is more flexible and maintainable in the long run. To change font settings using CSS, you can use the following properties:
    • font-family: This property specifies the font family to use for the text. You can specify multiple font families in a comma-separated list, and the browser will use the first font family that is available on the user’s system.font-size: This property specifies the size of the text in pixels.font-weight: This property specifies the boldness of the text.font-style: This property specifies the style of the text, such as normal, italic, or oblique.
    To apply these CSS properties to your text, you can use the <style> tag in the <head> section of your HTML document, or you can use inline CSS by adding the style attribute to the HTML element that you want to style.For example, the following CSS will change the font family of all of the text on the page to Arial, and the font size to 16 pixels:CSSbody { font-family: Arial, sans-serif; font-size: 16px; }

Q. Difference between container element and empty element in HTML

Container element: A container element is an HTML element that can contain other elements inside of it. Container elements have both an opening and closing tag.

Examples of container elements include:

  • <div>
  • <p>
  • <ul>
  • <ol>
  • <table>
  • <form>

Empty element: An empty element is an HTML element that does not contain any other elements inside of it. Empty elements only have an opening tag, and no closing tag.

Examples of empty elements include:

  • <img>
  • <br>
  • <hr>
  • <input>
  • <meta>

Q. Difference between container elements and empty elements:

  • Container elements can contain other elements inside of them, while empty elements cannot.
  • Container elements have both an opening and closing tag, while empty elements only have an opening tag.
  • Container elements are used to structure and format the content of a web page, while empty elements are used to insert specific types of content, such as images, line breaks, and horizontal rules.

Here is an example of a container element and an empty element:

HTML

<div>
  This is a paragraph of text.
  <img src="image.jpg" alt="An image">
</div>

Use code with caution. Learn morecontent_copy

In this example, the <div> element is a container element because it contains other elements inside of it, such as the paragraph of text and the image element. The <img> element is an empty element because it does not contain any other elements inside of it.

Container elements and empty elements are both important parts of HTML. Container elements are used to structure and format the content of a web page, while empty elements are used to insert specific types of content.


Q. How many heading levels are supported by html and name of them

HTML supports six levels of headings, which are denoted by the following tags:

  • <h1>
  • <h2>
  • <h3>
  • <h4>
  • <h5>
  • <h6>

<h1> is the most important heading, and <h6> is the least important heading. Headings are used to structure the content of a web page and to make it easier for users and search engines to understand the page.

Headings can also be used to create a table of contents for a web page. To do this, you can use the id attribute to give each heading a unique identifier. Then, you can use the toc element to generate a table of contents that links to each heading.

Here is an example of using headings to structure the content of a web page:

HTML

<h1>My Web Page</h1>
<h2>Introduction</h2>
<p>This is the introduction to my web page.</p>
<h2>Features</h2>
<ul>
  <li>Feature 1</li>
  <li>Feature 2</li>
  <li>Feature 3</li>
</ul>
<h2>Conclusion</h2>
<p>This is the conclusion to my web page.</p>

Use code with caution. Learn morecontent_copy

This code will render as follows:

My Web Page

Introduction

This is the introduction to my web page.

Features

* Feature 1
* Feature 2
* Feature 3

Conclusion

This is the conclusion to my web page.

Q. What are attributes in html? define the different attributes in <Body> tag.

Attributes in HTML

HTML attributes are used to provide additional information about HTML elements. They are specified in the opening tag of an element, and they are in the form of name-value pairs. For example, the following HTML code creates a paragraph element with the class attribute set to my-paragraph:

HTML

<p class="my-paragraph">This is a paragraph.</p>

There are many different HTML attributes, and each attribute has a specific purpose. Some common attributes include:

  • id: This attribute gives the element a unique identifier.
  • class: This attribute allows you to group similar elements together.
  • style: This attribute allows you to apply CSS styles to the element.
  • src: This attribute specifies the source of an image or other embedded resource.
  • href: This attribute specifies the URL of a link.

Attributes in the <body> tag

The <body> tag can have a number of different attributes, but the most common ones are:

  • class: This attribute allows you to group the entire body of the page together.
  • id: This attribute gives the body of the page a unique identifier.
  • style: This attribute allows you to apply CSS styles to the body of the page.
  • background: This attribute specifies the background color or image for the body of the page.
  • bgcolor: This attribute specifies the background color for the body of the page. (This attribute is deprecated in HTML 5.)
  • text: This attribute specifies the text color for the body of the page. (This attribute is deprecated in HTML 5.)

Here is an example of using attributes in the <body> tag:

HTML

<body class="my-body" id="my-body-id" style="background-color: #ffffff;">
  </body>

This code will create a body element with the class attribute set to my-body, the id attribute set to my-body-id, and the style attribute set to background-color: #ffffff;. This will make the background of the page white.

You can use attributes in the <body> tag to customize the appearance and behavior of your web pages. For more information about HTML attributes, please see the HTML documentation.

Q. What is <title> tag?

The <title> tag is an HTML element that defines the title of a web page. The title of a web page is displayed in the browser’s title bar and in search engine results pages (SERPs).

The <title> tag is required in all HTML documents. It should be placed in the <head> section of the document.

For example, the following HTML code defines a web page with the title “My Web Page”:

HTML

<!DOCTYPE html>
<html>
<head>
  <title>My Web Page</title>
</head>
<body>
  <h1>This is my web page.</h1>
</body>
</html>

Use code with caution. Learn morecontent_copy

When this code is rendered in a web browser, the title bar will display the title “My Web Page”.

The <title> tag is also used by search engines to index web pages. When a user searches for a keyword, the search engine will return a list of web pages that contain that keyword in the title or in the content of the page.

Therefore, it is important to write clear and descriptive titles for your web pages. This will help your pages rank higher in search engine results pages, and it will also make it easier for users to find your pages.

Here are some tips for writing good <title> tags:

  • Make sure the title is relevant to the content of the page.
  • Keep the title short and to the point.
  • Use the most important keywords in the title.
  • Avoid using all caps or excessive punctuation.

By following these tips, you can write <title> tags that will help your web pages rank higher in search engine results pages and be more user-friendly.

We will discuss about responsive code on next class…. Stay with us. Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *

Call Now Button