0 CSS Question and Answers

Wednesday, November 24, 2010

What is the need for CSS?

CSS is called as Cascading Style Sheets. This is used to enhance the features of web pages like formatting styles say bold, font size and so on and there by increase the visual appearance of web pages. These are specified inside an HTML tag. The use of CSS reduces time and enhances the web page design. With CSS it is possible to define layout of HTML documents like font, color, margin, line, height, width, images and so on. And another vital factor is CSS is supported by almost all web browsers and thus making it compatible for usage. With HTML one just defines the layout but with CSS added to it only enhances the design of document and thus catches the visual appearance and makes it easier to use for users. Thus the major difference between HTML and CSS will give the need for CSS in short. It is as follows. HTML is a structured content but CSS is used for formatting the structured content. The main need for CSS comes into picture when there was a need for a tool that is supported by all browsers which was achieved by CSS. Not only this in CSS the presentation style of document is separated ort excluded from the content of the document and thus making it much easier for users to understand and there by making it easier for maintenance. Thus in short the major advantages of CSS which led to the need for CSS are given below:

  • Supported by all browsers
  • Many sophisticated techniques available to achieve the formatting
  • Presentation style of document separated from content
  • Easier to Maintain the site
  • Very structured formatted layout achieved.


What is the relationship between CSS and HTML?

HTML is a markup language and it is used to create the content of a webpage.
CSS is a stylesheet language used to describe the presentation semantics of a document written in a markup language.

What are the major differences between CSS, CSS2 and CSS3?
A superset of CSS CSS2 includes a number of new capabilities like absolute relative and fixed positioning of elements the concept of media types support for aural style sheets and bidirectional text and new font properties such as shadows.

CSS3 is currently under development. The W3C maintains a CSS3 progress report. CSS3 is modularized and will consist of several separate recommendations.


What is the use of z-index?
z-index is used to show the order of the object.

What is the Difference between display:none and visibility: hidden?
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 in webpage.
 
What are the five possible values for "Position", and what is the default? 
absolute - Generates an absolutely positioned element positioned relative to the first parent element that has a position other than static. The element's position is specified with the "left" "top" "right" and "bottom" properties.

fixed - Generates an absolutely positioned element positioned relative to the browser window. The element's position is specified with the "left" "top" "right" and "bottom" properties.

relative - Generates a relatively positioned element positioned relative to its normal position so "left:20" adds 20 pixels to the element's LEFT position.

static - Default. No position the element occurs in the normal flow (ignores any top bottom left right or z-index declarations).

inherit - Specifies that the value of the position property should be inherited from the parent element.

How does a browser determine how an item is positioned?
.logo
{
position: absolute;
left: 100px;
top: 50px;
}
This kind of CSS helps the browser.
 
What is deference between cell padding and cell spacing ?
CELLSPACING controls the space between table cells. and CELLPADDING sets the amount of space between the contents of the cell and the cell wall.
 
What is the default margin and padding of h1,h2,h3,h4,h5,h6?
heading 1 (h1)
margin-left: 0px margin-right: 0px; margin-top: 8px; margin-bottom: 8px;

heading 2 (h2)
margin-left: 0px margin-right: 0px; margin-top: 10px; margin-bottom: 10px;

heading 3 (h3)
margin-left: 0px margin-right: 0px; margin-top: 12px; margin-bottom: 12px;

heading 4 (h4)
margin-left: 0px margin-right: 0px; margin-top: 16px; margin-bottom: 16px;

heading 5 (h5)
margin-left: 0px margin-right: 0px; margin-top: 20px; margin-bottom: 20px;

heading 6 (h6)
margin-left: 0px margin-right: 0px; margin-top: 28px; margin-bottom: 28px;
 
How do you rate CSS types as per priority and what are the reasons like Embedded, External, Inline? which one gets top priority and why
 
Choosing between External Embedded and Inline CSS is critical. It is always advisable to think long term. Even when you are working on a smaller module you never know its future. Moreover one must remember that CSS is all about 'look and feel' (style) while HTML is content; so better keep them separate.
As far as possible avoid Inline styles. If you are very sure that particular CSS classes are relevant only to the current web page it might be a good idea to opt for Embedded under certain circumstances. And ofcourse there are no cons while considering External stylesheet.
One thing is very important while using External stylesheets is the nomenclature. There are no fixed set of rules to follow but if you consider a broader view you can easily work out a fair plan for CSS class names.
To start with one can study some popular websites.
 
What are the steps to be followed for putting multiple sheets into one?  
 
You can use @import on top of the parent stylesheet on by one like

@import url("import1.css");
 
What are the rules to be followed for CSS-names?  
The name can contain characters a-z A-Z digits 0-9 period hyphen escaped characters Unicode characters 161-255 as well as any Unicode character as a numeric code however they cannot start with a dash or a digit.
 
How is more than one declaration attached to a selector?
Syntax:
Selector {declaration1; declaration2}
Example:
P {background: white; color: black}
 
What are the types of CSS rules? 
There are three types of CSS rules. They are namely:
HTML Selector
Class and
ID
 

  

0 JQuery Basics

Friday, November 19, 2010

Check out this SlideShare Presentation:

 
This is Sakthi, CSS Developer @ Chennai,India © 2010 | Designed by My Blogger Themes | Blogger Template by Blog Zone