What is HTML?
HTML, short for HyperText Markup Language, is the language of the World Wide Web and the standard text formatting language used for creating and displaying pages on the Internet.
Are HTML tags and elements the same thing?
This question is asked to distinguish between ‘tags,’ which are the markup symbols used to define elements (like <p>
), and ‘elements’ themselves, which include the tags and the content between them (like <p>content</p>
).
Do all tags and attributes need to be in lower or upper case?
Every tag and attribute in HTML should be in lowercase, although HTML5 is not case-sensitive. It’s a convention to use lowercase for better readability and consistency.
Is the <!DOCTYPE>
declaration necessary?
The <!DOCTYPE>
declaration is very necessary to write at the top of the HTML document because it tells the web browser which version of HTML the page is written in and how it should render the page.
Is it necessary to close tags in the order they are opened?
While it is not strictly necessary to close tags in the order they are opened, it is a good practice to do so for maintainable and error-free code. Not closing tags properly can lead to unexpected results and errors in document structure.
What is a Style Sheet?
A style sheet is used to create a consistent, transportable, and well-designed style template across web pages, describing the look and formatting of documents written in markup language.
Explain the layout of HTML.
HTML layout arranges the webpage, and various elements define the different parts of a webpage, such as <header>
, <nav>
, <section>
, <article>
, <aside>
, and <footer>
.
What is a marquee?
A marquee is used for scrolling text or images on a web page automatically in different directions.
What are the tags used to separate a section of text?
Tags like <br>
, <p>
, and <blockquote>
are used to separate lines of text, create new paragraphs, or define large quoted sections.
What is the difference between DIV and SPAN in HTML?
A <div>
is a block-level element used to group larger chunks of code, whereas a <span>
is an inline element used for a small chunk of HTML inside a line.
What is the purpose of using alternative texts in images?
Alternative texts define what the image is about, making it easier to understand image mappings and hotspots.
How to create a new HTML element?
New HTML elements can be created using document.createElement("elementName")
in a script.
Is the <!DOCTYPE html>
tag considered as an HTML tag?
No, it is a declaration to instruct the web browser about the HTML page version being used.
Why is a URL encoded in HTML?
URLs are encoded to convert non-ASCII characters into a format that can be used over the Internet using the ASCII character set.
What is the use of an iframe tag?
An iframe is used to display a web page within another web page.
What are the entities in HTML?
HTML character entities are used as replacements for reserved characters in HTML or characters not present on the keyboard.
Can you create multi-colored text on a web page?
Yes, multi-colored text can be created using <font color="color">
tags around the specific texts.
How to make a picture a background image of a web page?
Use the <body background="imageName">
tag after the </head>
tag.
What is the use of a span tag?
A <span>
tag is used for styling text, such as adding color, background, or highlighting text.
What is the advantage of collapsing white space?
HTML collapses multiple space characters into a single space, allowing for more readable code formatting without affecting the document’s spacing.
Explain the key differences between localStorage and sessionStorage objects.
localStorage
stores data with no expiry date and survives browser window closures, whereas sessionStorage
stores data for one session and clears it when the window closes.
Which tags are no longer valid in HTML5?
Tags such as <font>
, <dir>
, <isindex>
, <frameset>
, <noframes>
, <tt>
, and <strike>
or <s>
are deprecated in HTML5.
Why is SVG preferred for image formats?
SVG is preferred because it is easy to scale, can be edited with any text editor, and maintains high image quality regardless of resolution.
How do you center text in HTML5?
Since the <center>
tag is deprecated, you would use the CSS text-align
property on the desired element to center the text.
How to create a table in HTML5?
To create a table in HTML5, you use the <table>
element along with nested <tr>
(table row) and <td>
(table data) elements to define the rows and cells.
How to use the Geolocation API in HTML5?
The Geolocation API in HTML5 can be used to get the geographical position of a user. This can be done through JavaScript by calling the navigator.geolocation.getCurrentPosition()
method.
What are the significant goals of the HTML5 specification?
The goals of HTML5 include better semantic support for webpage structure, a stricter parsing standard for consistent cross-browser behavior and backward compatibility, replacing older HTML standards, offering rich interactive content like videos and animations without plugins, and ensuring seamless operation across multiple devices and platforms.
Can you list some important new features in HTML5?
Important new features in HTML5 encompass better error handling, enhanced support for embedding audio, graphics, and video content, extensions for the JavaScript API like caching, drag-and-drop, geolocation, storage, more markup to replace scripting, multi-device support, new attributes for better document structure, and semantic tags for modern web applications.
What are the differences between HTML and HTML5?
Differences include the availability of new attributes like async, charset, and ping in HTML5, a simpler doctype declaration, support for drag-and-drop, the ability to draw geometric shapes, out-of-the-box high-level audio and video support, the in-text use of MathML and SVG, and the ability of JavaScript to run in the background using Web Workers.
How do you implement the <video>
tag to embed a video?
To embed a video, use the <video>
tag with attributes for the source, dimensions, and controls, like so: <video src="http://www.example.com/amazing_video.mp4" width="640" height="360" controls></video>
.
What were the key goals for the HTML5 specification?
HTML5 aimed to deliver rich content without plugins, improve semantic support with new structural elements, ensure consistent cross-browser behavior, and provide better cross-platform support.
What are some key new features in HTML5?
New features include improved support for embedding media, extensions to the JavaScript API, introduction of web workers, new semantic elements, and new form controls.
What are “web workers”?
Web workers allow multi-threading in JavaScript, enabling scripts to run in the background without interrupting the user’s interaction with the page.
How is character encoding indicated in an HTML5 document?
The character set is indicated using the charset
attribute of the <meta>
tag within the <head>
element, which is simpler than the syntax used in older HTML standards.
What is the difference between an HTML specification and a browser’s implementation thereof?
The HTML specification sets the rules for valid documents and how browsers should interpret them. Browsers “support” a specification if they handle documents according to these rules. However, no browser supports the entire HTML5 specification, and developers must ensure cross-browser compatibility.
How should HTML5 semantic elements be used correctly?
The <header>
element should contain introductory content, while the <article>
element should enclose self-contained, independently distributable content, such as blog posts or news articles.