Home CSS CSS Important Question and Answers

CSS Important Question and Answers:

1. What is the difference between display:none and visibility: hidden?
Visibility:hidden keep the placeholder in the page, Display:none does not keep.

Display:none and Visibility:hidden both are hide the content from web page, Visibility:hidden create the space in web page, Display:none is not, this property totally refuse the content…

2. How do I have a non-repeating background image?
body {
background: white url(example.gif) no-repeat ;
color: black ;
}

3. What is the difference between ID and CLASS?

ID identifies and sets style to one and only one occurrence of an element while class can be attached to any number of elements. By singling out one occurrence of an element the unique value can be declared to said element.

CSS
#eva1 {background: red; color: white}
.eva2 {background: red; color: white}

HTML – ID

Paragraph 1 – ONLY THIS occurrence of the element P (or single occurrence of some other element) can be identified as eva1

Paragraph 2 – This occurrence of the element P CANNOT be identified as eva1

HTML – CLASS

Paragraph 1 – This occurrence of the element P can be classified as eva2

Paragraph 2 – And so can this, as well as occurrences of any other element,

4. What are the possible values of the “Position” attributes?

absolute
fixed
inherit
relative
static

By default, relative value is considered.

5. How to display a link without underline and display underline when mouseover on the link using CSS?
a
{
text-decoration:none;
}

a:hover
{
text-decoration:underline;
}

6. Explain inline, embedded and external style sheets .

There are three ways of inserting a style sheet:

1. External style sheet
2. Internal style sheet
3. Inline style

External Style Sheet :
An external style sheet is ideal when the style is applied to many pages.
With an external style sheet, you can change the look of an entire Web site by changing one file.
Each page must link to the style sheet using the tag. The tag goes inside the head section:
Internal Style Sheet :
An internal style sheet should be used when a single document has a unique style. Internal styles sheet needs to put in the head section of an HTML page, by using the

Inline Styles :
If only a small piece of code has to be styled then inline style sheets can be used.
An inline style loses many of the advantages of style sheets by mixing content with presentation.
To use inline styles you use the style attribute in the relevant tag.
The style attribute can contain any CSS property.
The example shows how to change the color and the left margin of a paragraph:

This is a paragraph.

You may also like

Leave a Comment