Css Questions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

ROLLNO.

- 19071221

QUESTIONS:-
Q1- What is a CSS selector?

Ans: -

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 CSS Element Selector:- The element selector selects all elements with the
specified element name.
E.G. all <p> elements on the page will be center-aligned, with a red text
color: 
p {
  text-align: center;
  color: red;
}
o CSS Id Selector:- The id of an element is unique within a page, so the id
selector is used to select one unique element!
To select an element with a specific id, write a hash (#) character,
followed by the id of the element.
E.G. it is applied to the HTML element with id="para1": 
#para1 
{
  text-align: center;
  color: red;
}
o CSS Class Selector:- The class selector selects HTML elements with a
specific class attribute. To select elements with a specific class, write a
period (.) character, followed by the class name.

E.G. all HTML elements with class="center" will be red and center-
aligned: 

.center {
  text-align: center;
  color: red;
}
o CSS Universal Selector:- The universal selector (*) selects all HTML
elements on the page.
o E.G. The CSS rule below will affect every HTML element on the page:
*{
  text-align: center;
  color: blue;
}
o CSS Group Selector:- The grouping selector selects all the HTML elements
with the same style definitions.

o Look at the following CSS code (the h1, h2, and p elements have the
same style definitions:
E.G. group the selectors, to minimize the code.
h1, h2, p {
  text-align: center;
  color: red;
}

Q2- Why is the external style sheet useful?

Ans: -

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 referring to 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. Thus we can say that it is very useful and it makes your work easy
while working on larger files.

Q3- What are the uses of an embedded style sheet?

Ans: -

Embedded style sheet gives us the privilege to define styles in one place in an HTML
document.
We can generate multiple classes using an embedded style sheet to use on multiple
tag types of a web page and also there is no extra downloading required for importing
the information.

Q4- Name the types of functions.

Ans:- The types of function are:

o Named - These type of functions contains name at the time of definition.


For Example:

function display()  

{  
document.writeln("Named Function");  
}  
display();  
o Anonymous - These type of functions doesn't contain any name. They are
declared dynamically at runtime.

var display=function()  
{  
document.writeln("Anonymous Function");  
}  
display();  

Q5- Is JavaScript case sensitive language?

Ans:- Yes, JavaScript is a case sensitive language. For example:

Var msg = "JavaScript is a case
sensitive language"; //Here, var should be used to declare a variable  
function display()   
{  
document.writeln(msg); // It will not display the result.  
}   
display();  

You might also like