FAQ On CSS
FAQ On CSS
FAQ On CSS
1) What is CSS?
CSS stands for Cascading Style Sheet. It is a popular styling language which is used with
HTML to design websites. It can also be used with any XML documents including plain XML,
SVG, and XUL.
SGML (Standard Generalized Markup Language) is the origin of CSS. It is a language that
defines markup languages.
o CSS2
o CSS2.1
o CSS3
o CSS4
CSS frameworks are the preplanned libraries which make easy and more standard compliant
web page styling. The frequently used CSS frameworks are: -
o Bootstrap
o Foundation
o Semantic UI
o Gumby
o Ulkit
8) Why background and color are the separate properties if they should always be set
together?
An Embedded style sheet is a CSS style specification method used with HTML. You can
embed the entire stylesheet in an HTML document by using the STYLE element
<style>
body {
background-color: linen;
h1 {
color: red;
margin-left: 80px;
</style>
It is a string that identifies the elements to which a particular declaration apply. It is also
referred as a link between the HTML document and the style sheet. It is equivalent of HTML
elements. There are several different types of selectors in CSS: -
o Selector
o Property
o Value
13) What is the use of CSS Opacity?
The CSS opacity property is used to specify the transparency of an element. In simple word,
you can say that it specifies the clarity of the image. In technical terms, Opacity is defined as
the degree to which light is allowed to travel through an object. For example:
<style>
img.trans {
opacity: 0.4;
</style>
The universal selector matches the name of any of the element type instead of selecting
elements of a specific type.
<style>
*{
color: green;
font-size: 20px;
</style>
15) Which command is used for the selection of all the elements of a paragraph?
The p[lang] command is used for selecting all the elements of a paragraph.
17) Name the property used to specify the background color of an element.
The background-color property is used to specify the background color of the element. For
example:
1. <style>
2. h2,p{
3. background-color: #b0d4de;
4. }
5. </style>
18) Name the property for controlling the image repetition of the background.
The background-repeat property repeats the background image horizontally and vertically.
Some images are repeated only horizontally or vertically.
1. <style>
2. body {
3. background-image: url("paper1.gif");
4. margin-left:100px;
5. }
6. </style>
19) Name the property for controlling the image position in the background.
The background-position property is used to define the initial position of the background
image. By default, the background image is placed on the top-left of the webpage.
1. center
2. top
3. bottom
4. left
5. right
The ruleset is used to identify that selectors can be attached with other selectors. It has two
parts:
An overall block is given to class selector while id selectors take only a single element
differing from other elements.
CSS Id Selector
1. <style>
2. #para1 {
3. text-align: center;
4. color: blue;
5. }
6. </style>
24) What is the difference between inline, embedded and external style sheets?
Inline: Inline Style Sheet is used to style only a small piece of code.
Syntax
Embedded: Embedded style sheets are put between the <head>...</head> tags.
Syntax
1. <style>
2. body {
3. background-color: linen;
4. }
5. h1 {
6. color: red;
7. margin-left: 80px;
8. }
9. </style>
External: This is used to apply the style to all the pages within your website by changing just
one style sheet.
Syntax
1. <head>
2. <link rel="stylesheet" type="text/css" href="mystyle.css">
3. </head>
RWD stands for Responsive Web Design. This technique is used to display the designed page
perfectly on every screen size and device, for example, mobile, tablet, desktop and laptop.
You don't need to create a different page for each device.
If a web page has a large number of images that take a longer time to load because each
image separately sends out an HTTP request. The concept of CSS sprites is used to reduce
the loading time for a web page because it combines the various small images into one
image. It reduces the number of HTTP requests and hence the loading time.
27) What is the difference between logical tags and physical tags?
o Physical tags are referred to as presentational markup while logical tags are useless
for appearances.
o Physical tags are newer versions, on the other hand, logical tags are old and
concentrate on content.
28) What is the CSS Box model and what are its elements?
The CSS box model is used to define the design and layout of elements of CSS.
The CSS float property is used to move the image to the right or left along with the texts to
be wrapped around it. It doesn't change the property of the elements used before it.
To understand its purpose and origin, let's take a look at its print display. In the print display,
an image is set into the page such that text wraps around it as needed.
In short, there is no easy way to restore to default values to whatever a browser uses.
The closest option is to use the 'initial' property value, which restores the default CSS values,
rather than the browser's default styles.
The z-index helps to specify the stack order of positioned elements that may overlap one
another. The z-index default value is zero and can take on either a positive or negative
number.
An element with a higher z-index is always stacked above than a lower index.
visibility: hidden hides the element, but it occupies space and affects the layout of the
document.
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <style>
5. h1.vis {
6. visibility: visible;
7. }
8.
9. h1.hid {
10. visibility: hidden;
11. }
12. </style>
13. </head>
14. <body>
15. <h1 class="vis">It is visible</h1>
16. <h1 class="hid">It is hidden</h1>
17.
18. <p>Note - Second heading is hidden, but it still occupy space.</p>
19. </body>
20. </html>
display: none also hides the element but not occupy space. It will not affect the layout of
the document.
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <style>
5. h1.vis {
6. display: block;
7. }
8.
9. h1.hid {
10. display: none;
11. }
12. </style>
13. </head>
14. <body>
15. <h1 class="vis">It is visible</h1>
16. <h1 class="hid">It is hidden</h1>
17.
18. <p>Note - Second heading is hidden and not occupy space.</p>
19. </body>
20. </html>
W3C stands for World Wide Web Consortium. Its purpose is to deliver the information of
the World Wide Web. It also develops rules and guidelines for the Web.
It gives the impression that the first image has smoothly evolved into the second one.
In CSS3, Transforms (matrix, translate, rotate, scale) module can be used to achieve
tweening.
The main difference between CSS2 and CSS3 is that CSS3 is divided into different sections
which are also known as modules. Unlike CSS2, CSS3 modules are supported by many
browsers.
Apart from that, CSS3 contains new General Sibling Combinators which is responsible for
matching the sibling elements with the given elements.