Practical Elements (CSS)
Practical Elements (CSS)
Answer: CSS outline the style of an HTML webpage, it is a language by which we can set
the behavior of an HTML webpage. It describes how the HTML content will be shown on
screen.
CSS controls the layout of several HTML web pages. CSS is referred to as the Cascading
Style Sheet.
Q #2) Name all the modules which are used in the current version of CSS.
Answer: There are several modules in CSS as stated below:
Selectors
Box Model
Backgrounds and Borders
Text Effects
2D/3D Transformations
Animations
Multiple Column Layout
User Interface.
Q #3) Distinguish between CSS2 and CSS3.
Answer:
There are several differences between CSS2 and CSS3.
CSS3 is divided into two various sections which are called a module. Whereas in
CSS2 everything accedes into a single document with all the information in it.
CSS3 modules are supported almost on every browser and on the other hand
modules of CSS and CSS2 are not supported in every browser.
In CSS3 we will find that many graphics related characteristics have been introduced
like “Border-radius or box-shadow, flexbox.
In CSS3, a user can precise multiple background images on a webpage by using
properties like background-image, background-position, and background-repeat
styles.
Q #4) Cite different types of CSS.
Answer: There are three types of CSS as mentioned below.
External – These are written in separate files.
Internal – These are cited at the top of the web page code document.
Inline – These are written right next to the text.
Q #5) Why is the external style sheet useful?
Answer: External style sheet is very useful as we write all the styling codes in a single file
and it can be used anywhere by just referencing the link of that external style sheet file.
So if we do any changes in that external file, then the changes can also be observed on the
webpage. So we can say that it is very useful and it makes your work easy while working on
larger files.
Q #11) How to align image vertically in a division that spans vertically on the whole
webpage?
Answer: It can be done by using the syntax verticle-align: middle in the <div1> element and
even we can bind the two text spans around with another span and after this, we have to
use verticle-align: middle in the content #icon.
Q #12) What is the difference between padding and margin?
Answer: In CSS, the margin is the property by which we can create space around
elements. We can even create space to the exterior defined borders.
In CSS we have margin property as follows:
margin-top
margin-right
margin-bottom
Margin-left
Margin property has some defined values as shown below.
Auto – using this property browser calculates the margin.
Length – It sets the margin values in px,pt,cm etc.
% – It sets the width % of the element.
Inherit – By this property we can inherit the margin property from the parent
element.
In CSS, padding is the property by which we can generate space around an element’s
content as well as inside any known border.
div {
padding-top: 60px;
padding-right: 40px;
padding-bottom: 50px;
padding-left: 70px;
ul {
list-style-type: none;
margin: 0;
padding: 0;
Q #17) What are the differences between relative and absolute in CSS?
Answer: The main difference between relative and absolute is that “relative” is used for the
same tag in CSS and it means that if we write the left:10px then the padding will shift to
10px in the left while absolute is totally relative to the non-static parent.
It means if we write left:10px then the result will be 10px far from the left edge of the parent
element.
<html>
<head>
<style>
.flex-container {
display: flex;
background-color: #f4b042;
background-color: #d60a33;
margin: 10px;
padding: 20px;
font-size: 30px;
</style>
</head>
<body>
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
</body>
</html>