HTML
HTML
HTML
1. What is HTML?
o Answer: HTML (HyperText Markup Language) is the standard
markup language used for creating web pages. It structures the
content on the web using elements and tags.
2. What are tags in HTML?
o Answer: Tags in HTML are keywords enclosed in angle brackets
(<>) used to define elements on a webpage. Most HTML tags
come in pairs (an opening tag <p> and a closing tag </p>).
3.
What is the difference between HTML and XHTML?
Answer: HTML is more flexible and less strict about syntax, while
XHTML (Extensible HTML) is stricter about syntax and must follow XML
rules. For instance, all tags must be properly closed in XHTML.
What is a semantic tag in HTML?
Answer: Semantic tags clearly describe the meaning of their content
to both the browser and the developer. Examples include <header>,
<footer>, <article>, <section>, and <nav>. They improve code readability
and SEO
What is the difference between block-level and inline elements?
Answer: Block-level elements (e.g., <div>, <p>) occupy the entire width
of their parent container and start on a new line, while inline elements
(e.g., <span>, <a>) take up only as much space as needed and don't
force line breaks.
What is the purpose of the DOCTYPE declaration in HTML?
Answer: The DOCTYPE declaration defines the HTML version being used.
It ensures that the browser renders the page correctly according to
HTML5 or other standards.
o Answer:
1. Padding: The space between the content and the element’s
border.
2. Margin: The space outside the element’s border,
separating it from other elements.
css
code
div {
padding: 10px;
margin: 20px;
Copy code
.box1 {
position: absolute;
z-index: 1;
.box2 {
position: absolute;
z-index: 2;
a:hover {
color: red;
input:focus {
border-color: blue;
li:nth-child(2) {
font-weight: bold;
Copy code
p::first-letter {
font-size: 2em;
color: blue;
h1::before {
Copy code
div {
display: block;
span {
display: inline;
img {
display: inline-block;
Copy code
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
Copy code
.grid-container {
display: grid;
grid-gap: 10px;
o Answer:
relative: The element is positioned relative to its normal
position.
absolute: The element is positioned relative to its nearest
positioned ancestor.
fixed: The element is positioned relative to the viewport
and remains fixed during scrolling.
sticky: The element is positioned relative to the scroll
position, toggling between relative and fixed.
css
Copy code
.relative {
position: relative;
top: 20px;
.absolute {
position: absolute;
top: 20px;
left: 50px;
.fixed {
position: fixed;
bottom: 0;
.sticky {
position: sticky;
top: 0;
Copy code
background-color: lightblue;
Copy code
p{
p{
Copy code
/* Transition */
button {
button:hover {
background-color: blue;
/* Animation */
@keyframes example {
0% {background-color: red;}
div {
<section id="home_section">
Information About Page
</section>
Example: When the user clicks on the “Contact Us” link, he will be
redirected to the “Contact Us section” on the same page.
HTML
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100%;
height: 400px;
</style>
</head>
<body>
<h2>Welcome to GeeksforGeeks</h2>
<p>
</p>
<div>
<h2>Home section</h2>
</div>
<div>
<h2>About Us section</h2>
</div>
<div id="CONTACTUS">
</div>
<div>
<h2>Team Section</h2>
</div>
</body>
</html>
Output
11. Are <b> and <strong> tags same? If not, then why?
HTML strong tag: The strong tag is one of the elements of HTML used
in formatting HTML texts. It is used to show the importance of the text
by making it bold or highlighting it semantically.
Syntax:
<strong> Contents... </strong>
HTML bold tag: The bold tag or <b> is also one of the formatting
elements of HTML. The text written under the <b> tag makes the text
bold presentationally to draw attention.
Syntax:
<b> Contents... </b>
The main difference between the <bold> tag & <strong> tag is that
the strong tag semantically emphasizes the important word or section
of words while the bold tag is just offset text conventionally styled
in bold. Click Here to know more.
What is the difference between <em> and <i> tags?
<i> tag: It is one of the elements of HTML which is used in formatting
HTML texts. It is used to define a text in technical terms, alternative
mood or voice, a thought, etc.
Syntax:
<i> Content... </i>
By default, the visual result is the same but the main difference
between these two tags is that the <em> tag semantically
emphasizes the important word or section of words while the <i> tag
is just offset text conventionally styled in italic to show alternative
mood or voice. Click Here to know the difference between them.
13. How are comments added in HTML?
The comment tag (<!– Comment –>) is used to insert comments in
the HTML code.
Types of HTML Comments: There are two types of comments in HTML
which are:
7. Single-line comment
Multi-lines comment
RGB Format
RGBA Format
4. Hexadecimal Notation
HSL
HSLA
Hue: Hue is the degree of the color wheel. Its value lies
between 0 to 360 where 0 represents red, 120 represents
green and 240 represents blue color.
Saturation: It takes a percentage value, where 100%
represents completely saturated, while 0% represents
completely unsaturated (gray).
3. Lightness: It takes a percentage value, where 100%
represents white, while 0% represents black.
Explanation:
8. href: The href attribute is used to specify the destination
address of the link used.
Text link: The text link is the visible part of the link.
Attribute Values:
_blank: It opens the link in a new window.