CSS Interview Q & A (WOWSIDE)
CSS Interview Q & A (WOWSIDE)
CSS Questions
1. What are the possible ways to apply CSS styles to a web page?
CSS can be applied in the following three ways:
• Linked: Create a separate .css file and add all the style for the web page there. Make sure the file is linked to the HTML
document(s) using the link tag
• Embedded: Inside the HTML document, open a style tag and inside that, add all styles just like you’d do on a linked file.
• Inline: This is done by adding a style attribute inside an HTML element.
.class {
color: black;
}
The difference between classes and ID’s is that a HTML element can accept multiple classes, but only one ID. That
means ID’s are unique for HTML elements.
9. What are grid systems and why do we use them in web pages?
Grid systems are structured rules that enable content to be stacked horizontally and vertically in a consistent and
sustainable way. They find heavily usage in today’s websites because they offer increased producitvity while coding,
they’re versatile and ideal for responsive layouts.
div {
background-color: #ccc;
background-image: url("img.png");
background-repeat: no-repeat;
background-position: right top;
}
div {
background: #ccc url("img.png") no-repeat right top;
}
12. List some of the new CSS propertied introduced with CSS3?
The following is a list of new properties added in CSS3:
• border-radius
• box-shadow
• text-shadow
• text-stroke
• background-size
• text-overflow
• resize
• transition
Also, other features like multiple backrounds which allows you to have two or more background in the very same selector
and flexible box model which ensures that elements behave predictably when the page layout must accommodate
different screen sizes and different display devices.
14. What is the CSS selector which allows you to target every element in a web page?
Called the universal selector and signed with an asterix (*), it sets all HTML element the same styling rules as defined in
the
property declarations. For example:
*{
margin: 0;
padding: 10px;
}
15. What are media queries and how are they used?
A media query consists of a media type and at least one expression that limits the style sheets’ scope by using media
features, such as width, height, and color. Media queries, added in CSS3, let the presentation of content be tailored to a
specific range of output devices without having to change the content itself. The usage of media queries is similar to this: