css
css
But remember:
1. Variety of Questions: The same questions can be asked in many different ways, so don't just
memorise the answers. Try to understand the concept behind each one.
2. Expect Surprises: There might be questions during your interview that are not on this list. It's
always good to be prepared for a few surprises.
3. Use This as a Starting Point: Think of this material as a starting point. It shows the kind of
questions you might encounter, but it's always good to study beyond this list during your course.
1. What is css?
In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to
demonstrate the visual form of a document or a typeface without relying on meaningful content.
Lorem ipsum may be used as a placeholder before the final copy is available.
● CSS stands for Cascading Style Sheets (Full Form)
● CSS describes how HTML elements are to be displayed on screen, paper, or in other
media.
● CSS saves a lot of work. It can control the layout of multiple web pages all at once.
● CSS is used to define styles for your web pages, including the design, layout and
variations in display for different devices and screen sizes.
4. Internal CSS :
Internal CSS is one of the most widely used CSS forms for changing, styling, and modifying the
unique styles of a single web page. You can use the internal CSS by integrating the <style>
element in the <head> section of a HTML web page.
Internal CSS can be applied to the whole web page but not on multiple web pages and you can
style several web pages by using the same code on every page.
Here is the basic syntax example with output:
OUTPUT :
6. CSS Selectors
CSS selectors are used to "find" (or select) the HTML elements you want to style. We can divide
CSS selectors into five categories:
● Simple selectors (select elements based on tag, id, class)
● Combinator selectors (select elements based on a specific relationship between them)
● Pseudo-class selectors (select elements based on a certain state)
● Pseudo-elements selectors (select and style a part of an element)
● Attribute selectors (select elements based on an attribute or attribute value)
7. Simple selectors :
● CSS id Selector: The id attribute is a unique identifier that is used to specify the
document. It is used by CSS and JavaScript to perform a certain task for a unique
element. In CSS, the id attribute is written using the # symbol followed by id
● CSS Class Selector: CSS syntax contains a selector, and a class is exactly that. It is
needed to stylize HTML elements – including changing colors, fonts, or the size of a text.
If you want to use a class, use a full stop (.) followed by the class name in a style block.
Next, use a bracket called a declaration block that contains the property to stylize the
element, such as text color or text size.
8. What is @media?
We can use @media for responsive web pages in every device like mobile, tablet, and laptop.
INPUT :
<!DOCTYPE html>
<html>
<head>
<title>Internal CSS</title>
<link rel="icon" href="image/(icon image name )">
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
OUTPUT :
Example :
15. What’s the difference between margin, padding, and border in css?
The css box model refers to the design and layout of the boxes that make up the content of a
web page. Margin is the space outside of the box, padding is the space inside the box, and
border is the line around the box.
27. How can you set the background image of an HTML element using CSS?
To set the background image of an HTML element using CSS, you can use the
background-image property.
31. What are the common issues with using float in layouts?
Common issues with using float include layout collapsing, overlapping content, and unequal
column heights. These can be mitigated using clear fix techniques or newer layout methods like
Flexbox or Grid.
33. How many values can the object-fit property take, and what do they do?
The object-fit property can take five values: fill, contain, cover, none, and scale-down.
● fill: The element fills the container, ignoring aspect ratio.
● contain: The element maintains aspect ratio and fits inside the container.
● cover: The element maintains aspect ratio and covers the entire container, possibly
cropping parts of the element.
● object-position :
This will create a box shadow with a horizontal offset of 2 pixels, a vertical offset of 2 pixels, a
blur radius of 4 pixels, and a black color.
.box { box-shadow: 2px 2px 4px #000000, -2px -2px 4px #ffffff; }
This will create two box shadows, one with a black shadow and another with a white shadow.
38. How can you make a box shadow appear only on specific sides of an element?
You can control the box shadow on specific sides of an element using the inset keyword in the
box-shadow property. For example:
This will create an inset shadow on the top and left sides of the element.
Box shadows are a versatile way to add depth and visual appeal to your web design, allowing
you to create various effects and make elements stand out on the page.
40. How many values can the position property take, and what do they mean?
The position property can take four values: static, relative, absolute, and fixed.
● static: Default value, the element follows the normal document flow.
● relative: The element is positioned relative to its normal position.
● absolute: The element is positioned relative to its closest positioned ancestor.
● fixed: The element is positioned relative to the viewport and remains fixed even during
scrolling.
41. What is the z-index property used for in combination with position?
The z-index property is used to control the stacking order of elements with a position value other
than static. It determines which elements appear in front of or behind other elements.
selector::before {
content: "Content to be inserted before";
}
selector::after {
content: "Content to be inserted after";
}
selector::pseudo-element {
property:value;
}
● ::before Pseudo-element: It is used to add some CSS property before an element when
that element is called.
● ::after Pseudo-element: It is used to add some CSS property after an element when
that element is called.
In CSS, the before and after pseudo-elements are used to insert content before or after
an element's content, respectively, without the need to modify the HTML markup. They
are part of the CSS content module and are commonly used in conjunction with the
content property.
.selector::before {
content: "→";
}
● ::after: This pseudo-element allows you to insert content after the content of the selected
element. Like ::before, it is used for decorative or additional content.
● In these examples, the CSS rules add a right-pointing arrow before the element with the
class .selector and a left-pointing arrow after it, respectively.
● Remember that ::before and ::after are pseudo-elements, so their content is not part of
the actual HTML structure and will not affect accessibility or be accessible by JavaScript.
They are purely presentational additions through CSS.
selector: pseudo-class{
property: value;
}
There are many Pseudo-classes in CSS but the ones which are most commonly used are as
follows:
.rotate-element {
transform: rotate(45deg);
}
● You can scale an element using the scale function within the transform property:
.scale-element {
transform: scale(1.5);
}
● You can translate an element using the translate function within the transform property:
.translate-element {
transform: translate(50px, 30px);
}
● You can skew an element using the skew function within the transform property:
.skew-element {
transform: skew(180deg);
}