HTML and Css
HTML and Css
Process:
Students to start zoom recording, they will be provided an assignment where they
can submit them.
Once all the questions are done & the feedback form is fully filled, submit the form
DUBX Method
The DUBX method is a structured approach to answering technical questions, which
consists of four components:
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 1
1. Definition: Providing a clear and concise explanation of the topic using key
technical terms.
2. Use case scenarios (real world use cases): Offering examples and explaining
when and why the topic is applied in various situations.
Academic Integrity
The results will not impact your unit movement. But your insincerity & dishonesty will
surely impact your unit movement. The intention is the give you a way to practice and
know where you stand.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 2
Answer
1. Definition:
HTML: Creating web pages by defining the structure, elements, and content
of the page, such as headings, paragraphs, lists, images, and links.
CSS: Styling web pages by defining visual attributes, such as colors, fonts,
layout, and responsive design for different devices and screen sizes.
3. Benefits: HTML and CSS work together to create well-structured and visually
appealing web pages. HTML provides the foundation for the content, while CSS
enhances the presentation and user experience. Separating content (HTML)
from presentation (CSS) allows for more efficient web development, easier
maintenance, and better accessibility.
4. Extra information: HTML and CSS are essential components of front-end web
development. Both languages have undergone multiple revisions, with the
current versions being HTML5 and CSS3. These latest versions introduce new
features and improvements, such as semantic elements, advanced selectors,
and support for animations and transitions.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 3
Answer
1. Definition:
Block element: A type of HTML element that, by default, starts on a new line
and takes up the full width available, effectively creating a "block" in the
layout.
Inline element: A type of HTML element that, by default, does not start on a
new line and only takes up as much width as necessary, allowing elements
to flow next to each other horizontally.
Inline elements: Commonly used for text formatting and smaller content
pieces. Examples include <span> , <a> , <em> , and <strong> .
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 4
elements allow for seamless formatting and organization within text-based
content.
Answer
2. Use case scenarios: The Box Model is used in all web page layouts, as it
determines the positioning, size, and spacing of elements on the page. It helps
developers control the appearance and alignment of content on a web page.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 5
3. Benefits: Understanding and leveraging the CSS Box Model allows for precise
control over the layout and design of web pages. It ensures consistent spacing
and positioning of elements, improving the overall look and user experience of a
website.
4. Extra information: The box-sizing property in CSS can be used to change how
the box model's dimensions are calculated. The default value is content-box ,
which means the element's width and height do not include padding and border.
The border-box value includes padding and border within the specified width
and height.
Answer
Inline: Apply styles directly to an HTML element using the style attribute.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 6
Internal: Add a <style> element within the <head> section of the HTML
document.
External: Create a separate .css file and link it to the HTML document
using a <link> element in the <head> section.
Benefits: Each method has its use cases and benefits. Inline CSS is useful for
quick, single-element styling, while internal CSS is suitable for small-scale
projects with limited styling. External CSS is the recommended approach for
larger projects, as it promotes better organization, maintainability, and
separation of concerns between HTML and CSS.
Answer
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 7
1. Definition: CSS Grid is a powerful two-dimensional layout system in CSS,
designed for creating complex and responsive web page layouts. It allows
developers to control the position, size, and alignment of elements along rows
and columns.
2. Use case scenarios: CSS Grid is used for designing web page layouts, such as
multi-column designs, responsive designs, and intricate grid-based structures. It
is particularly useful for building modern, responsive websites and web
applications.
3. Benefits: CSS Grid provides a robust and flexible way to create complex web
layouts with ease. It simplifies the layout process by offering precise control
over the position and sizing of elements, reducing the need for hacks or
workarounds. It also enhances responsiveness, making it easier to create
designs that adapt to different devices and screen sizes.
4. Extra information: CSS Grid can be used in conjunction with other layout
techniques, such as Flexbox, to create even more versatile and powerful
designs. Browser support for CSS Grid is excellent in modern browsers,
although it may require vendor prefixes or fallbacks for older browsers.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 8
Answer
1. Definition:
1. Benefits: Both Grid and Flex offer different advantages for web design. Grid
provides a powerful way to create complex, two-dimensional layouts, while
Flex offers a more straightforward and efficient method for distributing and
aligning content within a container. Depending on the specific layout
requirements, developers can choose the appropriate method to achieve
the desired outcome.
2. Extra information: Grid and Flex can be used together, allowing developers
to create versatile and responsive designs that adapt to various devices
and screen sizes. While both methods are widely supported in modern
browsers, older browsers may require vendor prefixes, fallbacks, or
alternative layout techniques.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 9
Answer
1. Definition: Inline styling refers to adding CSS styles directly to an HTML element
using the style attribute. The id attribute is used to assign a unique identifier to
an element for styling or scripting purposes.
2. Use case scenarios: Inline styling with an id can be used when a specific
element on a web page needs unique styling or JavaScript interaction that does
not apply to other elements.
3. Benefits: Inline styling with an id allows for quick, single-element styling without
the need for an external or internal stylesheet. However, it is generally not
recommended for large-scale projects or multiple elements, as it can lead to
code duplication and harder maintenance.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 10
Answer
1. Definition:
Padding: The space between an element's content and its border, within
the element's box.
3. Benefits: Understanding and utilizing padding and margin allows for precise
control over the positioning and spacing of elements in a web layout. This
improves the overall look and user experience of a website.
4. Extra information: Padding and margin can be set for each side of an element
individually (top, right, bottom, and left) or all at once using shorthand
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 11
properties. For example, padding: 10px 20px; would apply 10px padding to the
top and bottom, and 20px padding to the left and right sides of an element.
Answer
1. Definition: Selectors in CSS are patterns used to target and select HTML
elements in order to apply styles to them. They form the foundation of CSS
rules, determining which elements the styles should be applied to.
2. Use case scenarios: Selectors can target elements based on their element
type, class, id, attribute, or even their relationship to other elements. Examples
of selectors include:
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 12
Combinators: div > p , ul + p
1. Benefits: CSS selectors provide the flexibility and precision needed to target
specific elements or groups of elements within a web page. By
understanding and using various selectors, developers can efficiently apply
styles to the desired elements, improving the overall look and user
experience of a website.
Answer
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 13
either horizontally or vertically. It allows developers to control the position, size,
and alignment of elements within a flex container.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 14
Answer
1. Definition:
4. Extra information: There are other positioning values in CSS, such as static
(the default positioning), fixed , and sticky , which offer different levels of
control over an element's position in the layout. Choosing the right positioning
method depends on the specific requirements of the design and layout.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 15
Answer
Definition:
ID: A unique selector in CSS that should be used to target a single, specific
HTML element for styling or scripting purposes.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 16
Extra information: Classes and IDs can be combined with other selectors to
create more specific targeting rules. For example, div#header.navbar would
target a <div> element with the ID header and the class navbar . Additionally, it
is important to note that IDs must be unique within an HTML document,
whereas classes can be used multiple times.
Answer
3. Benefits: Aligning a container in the center of a page can improve the overall
appearance and user experience of a website. By centering important content
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 17
or elements, developers can direct users' attention to specific areas and create
a visually balanced layout.
4. Extra information: There are several methods for centering a container in CSS.
Some common approaches include:
Using Flexbox:
.parent {
display: flex;
justify-content: center;
align-items: center;
height: 100vh; /* or any desired height */
}
.parent {
display: grid;
justify-content: center;
align-content: center;
height: 100vh; /* or any desired height */
}
.parent {
position: relative;
height: 100vh; /* or any desired height */
}
.container {
position: absolute;
top: 50%;
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 18
left: 50%;
transform: translate(-50%, -50%);
}
Answer
2. Use case scenarios: This design pattern may be employed for various
purposes, such as creating icons, buttons, or other visual elements that
enhance the appearance and user experience of a website.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 19
3. Benefits: Combining shapes like rectangles and circles using CSS can result in
visually appealing designs, adding variety and interest to a web page. This
allows developers to create unique and engaging user interfaces.
4. Extra information: To create a rectangle with a circle inside it, you can use
HTML and CSS as follows:
HTML:
<div class="rectangle">
<div class="circle"></div>
</div>
CSS:
.rectangle {
width: 200px;
height: 100px;
background-color: #f00;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.circle {
width: 50px;
height: 50px;
background-color: #0f0;
border-radius: 50%;
}
In this example, the outer div with the class rectangle represents the rectangular
shape, while the inner div with the class circle represents the circular shape. By
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 20
using display: flex , justify-content: center , and align-items: center on the
.rectangle class, the circle is horizontally and vertically centered within the
rectangle.
The dimensions, colors, and other properties of the shapes can be adjusted as
needed to create the desired appearance.
Answer
1. Definition:
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 21
specific child element, enabling dynamic styling without JavaScript.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 22
Answer
2. Use case scenarios: Centering a div may be desired for various purposes, such
as aligning a login form, a modal, a "Coming Soon" page, or any other content
that should be the focal point of the user's attention.
3. Benefits: Centering a div can improve the overall appearance and user
experience of a website. By positioning important content or elements in the
center, developers can create a visually balanced layout and direct users'
attention to specific areas.
4. Extra information: There are several methods for centering a div in CSS. Some
common approaches include:
.center-div {
margin-left: auto;
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 23
margin-right: auto;
width: 50%; /* or any desired width */
}
.parent {
display: flex;
justify-content: center;
}
.parent {
display: flex;
align-items: center;
height: 100vh; /* or any desired height */
}
.parent {
display: flex;
justify-content: center;
align-items: center;
height: 100vh; /* or any desired height */
}
.parent {
display: grid;
justify-content: center;
align-content: center;
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 24
height: 100vh; /* or any desired height */
}
.parent {
position: relative;
height: 100vh; /* or any desired height */
}
.center-div {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
These methods can be used to center a div horizontally, vertically, or both. The
choice of method depends on the specific requirements and compatibility needs of
the project.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 25
Answer
1. Definition:
HTML5: The fifth and latest major version of HTML, which introduces new
features, capabilities, and improvements over previous versions. It is
designed to better support multimedia, application development, and
semantic elements for improved structure and accessibility.
HTML: Used for creating simple web pages, primarily consisting of text,
images, and basic formatting.
HTML5: Suitable for creating modern web pages and applications that
require multimedia integration, advanced graphics, forms, and interaction
capabilities, such as video players, drag-and-drop functionality, or canvas
elements for creating 2D and 3D graphics.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 26
3. Benefits: The transition from HTML to HTML5 has brought several benefits,
including enhanced support for multimedia, better semantic elements for
improved structure and accessibility, and new APIs for creating rich, interactive
web applications. HTML5 reduces the reliance on third-party plugins like Flash,
resulting in faster load times, better performance, and improved compatibility
across devices.
4. Extra information: Some key differences between HTML and HTML5 include:
Multimedia support: HTML5 provides native support for audio and video
playback with the <audio> and <video> elements, eliminating the need for
third-party plugins like Flash.
It is important to note that HTML5 is now the standard for web development, and
modern browsers have adopted its features and capabilities.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 27
Answer
<!DOCTYPE html>
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 28
For earlier versions of HTML, the Doctype declaration is more complex and includes
references to a Document Type Definition (DTD). For example, here is the Doctype
for HTML 4.01 Strict:
Answer
1. Definition:
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 29
is equal to or greater than the specified min-width value, the styles within
the media query will take effect.
2. Use case scenarios: Both min-width and max-width are used in media queries
to create responsive designs, adapting the layout and styles of a web page
according to the viewport width. These properties allow developers to target
specific device widths or ranges, ensuring optimal presentation and user
experience across various devices and screen sizes.
Applying styles for tablets and larger devices (viewport width 768px and
above):
Applying styles for a specific range of viewport widths (e.g., between 768px
and 1023px):
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 30
@media (min-width: 768px) and (max-width: 1023px) {
/* Styles for devices with viewport widths between 768
}
These examples demonstrate how min-width and max-width can be used in media
queries to target specific device widths or ranges, allowing developers to create
responsive designs that adapt to various screen sizes.
Answer
1. Definition: Meta tags are HTML elements used to provide metadata about a
web page. They are placed within the <head> section of an HTML document and
can contain information such as the page's title, description, author, keywords,
and other relevant data. Meta tags do not directly affect the visual appearance
of the web page but can have an impact on its search engine optimization
(SEO) and how it is displayed in search results or when shared on social media
platforms.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 31
2. Use case scenarios: Meta tags are used to provide information to search
engines, social media platforms, and other web services about the content of a
web page. They can help improve SEO, make the content more shareable, and
enhance the user experience by providing relevant information when the web
page is shared or displayed in search results.
3. Benefits: Using meta tags can improve a web page's visibility in search engine
results, increase the likelihood of users clicking on the page, and enhance the
presentation of the page when shared on social media platforms. Properly
implemented meta tags can lead to better search engine rankings, increased
organic traffic, and improved user engagement.
browser's title bar or tab and used by search engines as the main title for
search results.
<title>Page Title</title>
page's content. Although its impact on SEO is debatable, it can still be used
to help search engines understand the content and context of the page.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 32
<meta property="og:title"> , <meta property="og:description"> , <meta
Implementing relevant and well-structured meta tags can improve a web page's
SEO, user engagement, and overall performance on search engines and social
media platforms.
Answer
1. Definition: CSS positions are a set of properties used to control the positioning
and layout of HTML elements on a web page. By applying different position
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 33
values, developers can manipulate the position of elements relative to their
default location, the browser window, or other elements on the page.
2. Use case scenarios: CSS positions are used to create various types of layouts,
control the flow of elements on a page, or create fixed, sticky, or overlapping
elements. They can be used to customize the appearance and organization of
web page content for improved user experience and responsive design.
3. Benefits: Using CSS positions provides flexibility and control over the
placement of elements on a web page, allowing developers to create complex
and visually appealing layouts. It also enables the creation of dynamic and
interactive user interfaces, such as sticky headers, modals, or tooltips.
static : The default position value for all elements. Elements with a static
position are not affected by the top , right , bottom , or left properties and
are positioned according to the normal flow of the document.
normal position in the document flow. The top , right , bottom , and left
properties can be used to adjust the element's position without affecting the
layout of surrounding elements.
window or viewport, remaining in the same position even when the page is
scrolled. The top , right , bottom , and left properties can be used to
position the element.
elements until a specified scroll position is reached, after which they act like
fixed positioned elements. The top , right , bottom , and left properties
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 34
can be used to define the scroll position at which the element becomes
fixed.
Using the appropriate CSS position types allows developers to create intricate and
engaging layouts, control element placement, and improve the user experience on a
web page.
Answer
1. Definition: Semantic tags are HTML elements that convey meaning about the
structure and content of a web page to both browsers and developers. These
tags provide context and help describe the purpose of the content within the
element, making it easier for search engines to understand and index the page
and for developers to maintain and understand the code.
2. Use case scenarios: Semantic tags are used to structure web pages, improve
accessibility, and provide meaningful information about the content for search
engines and web services. They help create well-organized and easily
interpretable web pages, benefiting both users and developers.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 35
3. Benefits: Using semantic tags in HTML documents improves the overall
structure and organization of the content, making it more accessible and user-
friendly. It also enhances search engine optimization (SEO), as search engines
can better understand the purpose and context of the content, potentially
leading to better rankings and visibility.
<main>: Indicates the main content of the web page, which is unique and
central to the purpose of the page.
Using semantic tags helps create a clear and meaningful structure for web content,
which benefits both users and developers by improving accessibility, user
experience, and search engine optimization.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 36
Answer
1. Definition: HTML5 is the fifth and latest major version of the HTML standard,
introducing new features, elements, and APIs that enhance the capabilities of
web pages and applications. It is designed to provide better support for
multimedia, improve the semantic structure of documents, and enable more
interactive and dynamic user experiences.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 37
Better form control with new input types and attributes, making it easier to
create more user-friendly and interactive forms.
Greater support for web application development with new APIs for features
like offline storage, geolocation, and web workers.
Multimedia elements: <video> and <audio> for embedding video and audio
content, respectively, without the need for third-party plugins like Flash.
New form input types: email , tel , url , number , range , date , time , and
more, along with new attributes like placeholder , autofocus , required , and
pattern .
Web application APIs: APIs for features like offline storage (localStorage
and sessionStorage), geolocation, web workers, and more.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 38
Answer
2. Use case scenarios: Watermarks can be used on web pages for various
purposes, such as:
3. Benefits: Watermarks can provide visual cues that help protect your content and
establish brand presence. They can discourage unauthorized use of your
content and ensure that viewers can identify the source or owner of the content.
4. Extra information: To create a watermark using HTML and CSS, follow these
steps:
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 39
a. Create an HTML container element with a relative position, such as a <div>
element.
b. Place the main content and the watermark element (e.g., another <div> ,
<img> , or <span> ) inside the container.
c. Use CSS to position the watermark element with an absolute position and a
lower z-index value than the main content.
d. Style the watermark element with the desired transparency, color, or other
visual properties.
Example code:
<!DOCTYPE html>
<html>
<head>
<style>
.container {
position: relative;
}
.watermark {
position: absolute;
bottom: 10px;
right: 10px;
color: rgba(255, 255, 255, 0.5);
font-size: 24px;
z-index: 1;
}
.content {
z-index: 0;
}
</style>
</head>
<body>
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 40
<div class="container">
<img class="content" src="your_image.jpg" alt="Your Content
<div class="watermark">Your Watermark</div>
</div>
</body>
</html>
This example demonstrates how to create a watermark using HTML and CSS,
positioning a semi-transparent text element over an image element. The same
approach can be applied to other types of content and customized according to your
specific needs.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 41
Answer
1. Definition: These elements are semantic tags in HTML5 that convey meaning
about the structure and content of a web page. They help create a more
organized and meaningful structure for web content, improving accessibility,
user experience, and search engine optimization.
2. Use case scenarios: These semantic tags are used to structure web pages and
provide meaningful information about the content for search engines, web
services, and developers. They help create well-organized and easily
interpretable web pages, benefiting both users and developers.
4. Extra information: Below are brief descriptions of the mentioned semantic tags:
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 42
thematic grouping of content, such as chapters, tabbed content, or any
related set of items.
By using these semantic tags, developers can create a clear and meaningful
structure for web content, which benefits both users and developers by improving
accessibility, user experience, and search engine optimization.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 43
Answer
1. Definition: The <video> and <audio> tags are HTML5 elements used to embed
video and audio content in a web page, respectively. These elements provide
native multimedia support without the need for third-party plugins like Flash.
2. Use case scenarios: The <video> and <audio> tags are used when you want to
embed multimedia content directly into your web page, such as:
3. Benefits: Using the <video> and <audio> tags in HTML5 offers several benefits,
such as:
More control over the multimedia content with built-in attributes and
JavaScript APIs.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 44
4. Extra information: To use the <video> and <audio> tags, follow these steps:
For <video> :
For <audio> :
<audio controls>
<source src="your_audio.mp3" type="audio/mpeg">
<source src="your_audio.ogg" type="audio/ogg">
Your browser does not support the audio tag.
</audio>
The controls attribute adds built-in controls like play, pause, and volume to
the multimedia elements.
The <source> element specifies the different file formats for better
compatibility across various browsers. If a browser does not support a
specific format, it will try the next available format.
The text inside the <video> and <audio> tags will be displayed if the browser
does not support these elements.
By using the <video> and <audio> tags, developers can easily embed multimedia
content directly into their web pages, providing a more engaging and interactive
user experience.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 45
27. What is a flex-box? Explain justify-content, justify-
items, justify-self, align-items, align-content & align-self
Answer
2. Use case scenarios: Flexbox is used when you need a flexible and adaptive
layout for your web page elements, such as:
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 46
Automatic adaptation to available space, making it suitable for responsive
designs.
justify-content : This property aligns items along the main axis (horizontally,
by default) of the flex container. It accepts values such as flex-start , flex-
justify-items : This property is not specific to flexbox but to the CSS Box
Alignment Module. It aligns grid items or flex items along the inline (row)
axis. In the case of flexbox, it has no effect unless applied to a flex
container that is also a grid container.
align-items : This property aligns items along the cross axis (vertically, by
default) of the flex container. It accepts values such as flex-start , flex-
end , center , baseline , and stretch .
: This property aligns the flex container's lines within the flex
align-content
container when there is extra space on the cross axis. It accepts values
such as flex-start , flex-end , center , space-between , space-around , and
stretch .
align-self : This property allows individual flex items to override the align-
items value set on the flex container. It accepts the same values as align-
items .
By using flexbox and its properties, developers can create flexible and responsive
layouts that easily adapt to different screen sizes and devices.
Know where you stand: Masai self-rating interview preparation [HTML & CSS] 47