Enable java / javascript

What is Java?

Java is a computer programming language.

Can you enable Java or install Java Plugin in a smartphone browser?

No. You cannot enable Java or installJava Plugin in a smartphone browser. Also Smartphone browsers do not supportApplets(Applet is a small application which runs on browsers with the help of Java). If you really need to use a Java Plugin, use it on a Desktop PC or on aMAC.

What is JavaScript?

JavaScript is an object-oriented computer programming language commonly used to create interactive effects within web browsers.

Why do you need to enable JavaScript in your smartphone browser?

You need to enable JavaScript if you are having difficulty loading websites with interactive elements such as shopping carts or if a website is requesting you to enable JavaScript to load some kind ofinteractive elements.

By default, all Android browsers haveJavaScript turned on. If yours got turned off by accident, or you toggled it off and forgot how to toggle it back, see the steps below to learn how to turn it back on.

How to enable JavaScript on your Android smartphone:

Step 1. Open your default browser('Internet' or 'Browser') and click on the top right Menu(options).

 

Step 2. Click on 'Settings', then click on'Advanced'.

 

 

Step 3. Check the 'Enable JavaScript'option if it is unchecked.

Note: If you are using Google Chrome follow the below steps:

Step 1. Open Chrome and click on the top right Menu(options).

Step 2. Click on 'Settings', then click on'Content Settings'.

Step 3. Check the 'Enable JavaScript'option if it is unchecked.

MySQL Interview Questions

MySQL Interview Questions

1. What is MySQL? 

MySQL is an open source DBMS which is built, supported and distributed by MySQL AB (now acquired by Oracle)

2. What are the technical features of MySQL? 

MySQL database software is a client or server system which includes

Multithreaded SQL server supporting various client programs and libraries

Different backend

Wide range of application programming interfaces and

Administrative tools.

3. Why MySQL is used?

MySQL database server is reliable, fast and very easy to use.  This software can be downloaded as freeware and can be downloaded from the internet.

4. What are Heap tables?

HEAP tables are present in memory and they are used for high speed storage on temporary

basis.

• BLOB or TEXT fields are not allowed

• Only comparison operators can be used =, <,>, = >,=<

• AUTO_INCREMENT is not supported by HEAP tables

• Indexes should be NOT NULL

5. What is the default port for MySQL Server?

The default port for MySQL server is 3306.

6.  What are the advantages of MySQL when compared with Oracle? 

MySQL is open source software which is available at any time and has no cost involved.

MySQL is portable

GUI with command prompt.

Administration is supported using MySQL Query Browser

7. Differentiate between FLOAT and DOUBLE? 

Following are differences for FLOAT and DOUBLE:

• Floating point numbers are stored in FLOAT with eight place accuracy and it has four bytes.

• Floating point numbers are stored in DOUBLE with accuracy of 18 places and it has eight bytes.

 8. Differentiate CHAR_LENGTH and LENGTH?

CHAR_LENGTH  is character count whereas the LENGTH is byte count. The numbers are same for Latin characters but they are different for Unicode and other encodings.

9. How to represent ENUMs and SETs internally? 

ENUMs and SETs are used to represent powers of two because of storage optimizations.

10. What is the usage of ENUMs in MySQL?

ENUM is a string object used to specify set of predefined values and that can be used during table creation.

1

Create table size(name ENUM('Small', 'Medium','Large');

 11. Define REGEXP? 

REGEXP is a pattern match in which  matchespattern anywhere in the search value.

12. Difference between CHAR and VARCHAR? 

Following are the differences between CHAR and VARCHAR:

CHAR and VARCHAR types differ in storage and retrieval

CHAR column length is fixed to the length that is declared while creating table. The length value ranges from 1 and 255

When CHAR values are stored then they are right padded using spaces to specific length. Trailing spaces are removed when CHAR values are retrieved.

 13. Give string types available for column?

The string types are:

SET

BLOB

ENUM

CHAR

TEXT

VARCHAR

14. How to get current MySQL version?

1

SELECT VERSION ();

is used to get the current version of MySQL.

 15. What storage engines are used in MySQL? 

Storage engines are called table types and data is stored in files using various techniques.

Technique involves:

Storage mechanism

Locking levels

Indexing

Capabilities and functions.

16. What are the drivers in MySQL?

Following are the drivers available in MySQL:

PHP Driver

JDBC Driver

ODBC Driver

C WRAPPER

PYTHON Driver

PERL Driver

RUBY Driver

CAP11PHP Driver

Ado.net5.mxj

17. What does a TIMESTAMP do on UPDATE CURRENT_TIMESTAMP data type?

TIMESTAMP column is updated with Zero when the table is created.  UPDATE CURRENT_TIMESTAMP modifier updates the timestamp field to  currenttime whenever there is a change in other fields of the table.

18. What is the difference between primary key and candidate key?

Every row of a table is identified uniquely by primary key. There is only one primary key for a table.

Primary Key is also a candidate key. By common convention, candidate key can be designated as primary and which can be used for any foreign key references.

19. How do you login to MySql using Unix shell?

We can login through this command:

# [mysql dir]/bin/mysql -h hostname -u <UserName> -p <password>

20. What does myisamchk do?

It compress the MyISAM tables, which reduces their disk or memory usage.

21. How do you control the max size of a HEAP table?

Maximum size of Heal table can be controlled by MySQL config variable called max_heap_table_size.

22. What is the difference between MyISAM Static and MyISAM Dynamic?

In MyISAM static all the fields will have fixed width. The Dynamic MyISAM table will have fields like TEXT, BLOB, etc. to accommodate the data types with various lengths.

MyISAM Static would be easier to restore in case of corruption.

23. What are federated tables?

Federated tables which allow access to the tables located on other databases on other servers.

24. What, if a table has one column defined as TIMESTAMP?

Timestamp field gets the current timestamp whenever the row gets altered.

25. What happens when the column is set to AUTO INCREMENT and if you reach maximum value in the table?

It stops incrementing. Any further inserts are going to produce an error, since the key has been used already.

26. How can we find out which auto increment was assigned on Last insert?

LAST_INSERT_ID will return the last value assigned by Auto_increment and it is not required to specify the table name.

27. How can you see all indexes defined for a table?

Indexes are defined for the table by:

SHOW INDEX FROM <tablename>;

28. What do you mean by % and _ in the LIKE statement?

% corresponds to 0 or more characters, _ is exactly one character in the LIKE statement.

29. How can we convert between Unix & MySQL timestamps?

UNIX_TIMESTAMP is the command which converts from MySQL timestamp to Unix timestamp

FROM_UNIXTIME is the command which converts from Unix timestamp to MySQL timestamp.

30. What are the column comparisons operators?

The = , <>, <=, <, >=, >,<<,>>, <=>, AND, OR, or LIKE operators are used in column comparisons in SELECT statements.

 31. How can we get the number of rows affected by query?

Number of rows can be obtained by

1

SELECT COUNT (user_id) FROM users;

32.  Is Mysql query is case sensitive?

No.

1

2

3

SELECT VERSION(), CURRENT_DATE;

SeLect version(), current_date;

seleCt vErSiOn(), current_DATE;

 All these examples are same. It is not case sensitive.

33. What is the difference between the LIKE and REGEXP operators?  

LIKE and REGEXP operators are used to express with ^ and %.

1

2

SELECT * FROM employee WHERE emp_nameREGEXP "^b";

SELECT * FROM employee WHERE emp_nameLIKE "%b";

 34. What is the difference between BLOB AND TEXT?

A BLOB is a binary large object that can hold a variable amount of data. There are four types of BLOB –

TINYBLOB

BLOB

MEDIUMBLOB and

LONGBLOB

They all differ only in the maximum length of the values they can hold.

A TEXT is a case-insensitive BLOB. The four TEXT types

TINYTEXT

TEXT

MEDIUMTEXT and

LONGTEXT

They all correspond to the four BLOB types and have the same maximum lengths and storage requirements.

The only difference between BLOB and TEXT types is that sorting and comparison is performed in case-sensitive for BLOB values and case-insensitive for TEXT values.

35. What is the difference betweenmysql_fetch_array and mysql_fetch_object?

Following are the differences betweenmysql_fetch_array and mysql_fetch_object:

mysql_fetch_array() -Returns a result row as an associated array or a regular array from database.

mysql_fetch_object –  Returns a result row as object from database.

36. How can we run batch mode in mysql?

Following commands are used to run in batch mode:

1

2

mysql ;

mysql mysql.out

 37. Where MyISAM table will be stored and also give their formats of storage?

Each MyISAM table is stored on disk in three formats:

The ‘.frm’ file stores the table definition

The data file has a ‘.MYD’ (MYData) extension

The index file has a ‘.MYI’ (MYIndex) extension

38. What are the different tables present in MySQL?

Total 5 types of tables are present:

MyISAM

Heap

Merge

INNO DB

ISAM

MyISAM is the default storage engine as of MySQL .

39. What is ISAM?

ISAM  is abbreviated as Indexed Sequential AccessMethod.It was developed by IBM to store and retrieve data on secondary storage systems like tapes.

 40. What is InnoDB?

lnnoDB is a transaction safe storage engine developed by Innobase Oy which is a Oracle Corporation now.

41. How MySQL Optimizes DISTINCT?

DISTINCT is converted to a GROUP BY on all columns and it will be combined with ORDER BY clause.

1

SELECT DISTINCT t1.a FROM t1,t2 where t1.a=t2.a;

42. How to enter Characters as HEX Numbers?

If you want to enter characters as HEX numbers, you can enter HEX numbers with single quotes and a prefix of (X), or just prefix HEX numbers with (Ox).

A HEX number string will be automatically converted into a character string, if the expression context is a string.

43. How to display top 50 rows?

In MySql, top 50 rows are displayed by using this following query:

1

2

SELECT * FROM

LIMIT 0,50;

 

44. How many columns can be used for creating Index?

Maximum of 16 indexed columns can be created for any standard table.

45. What is the different between NOW() and CURRENT_DATE()?

NOW () command is used to show currentyear,month,date with hours,minutes and seconds.

CURRENT_DATE() shows current year,month and date only.

46. What are the objects can be created using CREATE statement?

Following objects are created using CREATE statement:

DATABASE

EVENT

FUNCTION

INDEX

PROCEDURE

TABLE

TRIGGER

USER

VIEW

47. How many TRIGGERS are allowed in MySqltable?

SIX triggers are allowed in MySql table. They are as follows:

BEFORE INSERT

AFTER INSERT

BEFORE UPDATE

AFTER UPDATE

BEFORE DELETE and

AFTER DELETE

48. What are the nonstandard string types?

Following are Non-Standard string types:

TINYTEXT

TEXT

MEDIUMTEXT

LONGTEXT

49. What are all the Common SQL Function?

CONCAT(A, B) – Concatenates two string values to create a single string output. Often used to combine two or more fields into one single field.

FORMAT(X, D) – Formats the number X to D significant digits.

CURRDATE(), CURRTIME() – Returns the current date or time.

NOW() – Returns the current date and time as one value.

MONTH(), DAY(), YEAR(), WEEK(), WEEKDAY() – Extracts the given data from a date value.

HOUR(), MINUTE(), SECOND() – Extracts the given data from a time value.

DATEDIFF(A, B) – Determines the difference between two dates and it is commonly used to calculate age

SUBTIMES(A, B) – Determines the difference between two times.

FROMDAYS(INT) – Converts an integer number of days into a date value.

50. Explain Access Control Lists.

An ACL (Access Control List) is a list of permissions that is associated with an object. This list is the basis for MySQL server’s security model and it helps in troubleshooting problems like users not being able to connect.

MySQL keeps the ACLs (also called grant tables) cached in memory. When a user tries to authenticate or run a command, MySQL checks the authentication information and permissions against the ACLs, in a predetermined order.

JQuery Interview Questions

JQuery Interview Questions

1. What is jQuery?

jQuery is not a programming language but a well written JavaScript code. It is a JavaScript code, which do document traversing, event handling, Ajax interactions and Animations.

 

2. Why jQuery is needed?

jQuery is needed for the following list:

·         Used to develop browser compatible web applications

·         Improve the performance of an application

·         Very fast and extensible

·         UI related functions are written in minimal lines of codes

·         

 

3. Whether jQuery HTML work for both HTML and XML documents?

No, jQuery HTML only works for HTML documents not for XML Documents.

 

4. What are the methods used to provide effects?

Some of the effects methods are:

·         Show()

·         Hide()

·         Toggle()

·         FadeIn()

·         FadeOut()

 

5. What is the advantage of using minimized version of jQuery?

Efficiency of web page increases when minimized version of jQuery is used.min.js file will be more than 50% less than the normal js file. Reduction in the file size makes the web page faster.  

 

6. Is jQuery is a JavaScript or JSON library file?

jQuery is a library of JavaScript file and it consists of DOM, event effects and the Ajax functions. jQuery is said to be a single JavaScript file.

 

7. Which operating system is more compatible with jQuery?

Mac, Windows and Linux are more compatible with the jQuery.

 

8. How can we include jQuery library in ASP.Net project?

Download the jQuery library from jQuery.com and include that reference in the asp.net page.

 

9. Which command will give a version of jQuery?

The command $.ui.version returns jQuery UI version.

 

10. In what scenarios jQuery can be used?

jQuery can be used in following scenarios:

Apply CSS static or dynamic Calling functions on events Manipulation purpose Mainly for Animation effects

 

11. What is the difference between find and children methods?

Find method is used to find all levels down the DOM tree but children find single level down the DOM tree.

 

12. What is jQuery connect?

A ‘ jQuery connect’  is a plugin used to connect or bind a function with another  function. Connect is used to execute function from any other function or plugin is executed.

 

13. How to use connect?

Connect can be used by downloading jQuery connect file from jQuery.com and then include that file in the HTML file. Use $.connect function to connect a function to another function.

 

14. What are the features of jQuery, has been used in web applications? jQuery uses features like

Sliding, File uploading and accordian in web applications.

 

15. What are the browser related issues for jQuery?

Browser compatibility of jQuery plugin is an issue and needs lot of time to fix it.

 

 16 . Whether we need to add jQuery file in both Master and Content page?

jQuery file should be added to the Master page and can use access from the content page directly without having any reference to it.

 

17. What are the basic selectors in jQuery?

Following are the basic selectors in jQuery:

·         Element ID

·         CSS Name

·         Tag Name

·         DOM hierarchy

 

18. Can we call C# code behind using jQuery?

Yes, we can call C# code from jQuery as it supports .net application.

 

19. What is the use jQuery.data method?

jQuery.data methods is used to associate the data with the DOM nodes and the objects. This data method makes the jQuery code clear and concise.

 

20. What is the use of each function in jQuery?

Each function is used to iterate each and every element of an object. It is used to loop DOM elements, arrays and the object properties.

 

21. What is the difference between size and length of jQuery?

Size and length both returns the number of element in an object. But length is faster than the size because length is a property and size is a method.

 

22. Can we add more than one ‘document.ready’ function in a page?

Yes, we can add more than one document.readyfunction in a page. But, body.onload can be added once in a page.

 

23. What is the use of jQuery load method?

jQuery load method is a powerful AJAX method which is used to load the data from a server and assign the data into the element without loading the page. 24. Whether our own specific characters are used in place of $ in jQuery?

Yes, We can use our own variable in place of $ by suing the method called no Conflict () method.

var sample = $.noConflict()

 

25. What are the four parameters used for jQuery Ajax method?

The four parameters are

·         URL - Need to specify the URL to send the request

·         type - Specifies type of request(Get or Post)

·         data - Specifies data to be sent to server

·         Cache - Whether the browser should cache the requested page

 

26 . What is the use of jQuery filter?

The jQuery filter is used to filter the certain values from the object list based on the criteria. Example is to filter certain products from the master list of products in a cart website.

 

27. Which program is useful for testing jQuery?

QUnit is used to test jQuery and it is very easy and efficient.

 

28. What is CDN?

CDN is abbreviated as Content Distribution network and it is said to be a group of companies in different location with network containing copies of data files to maximize bandwidth in accessing the data.

 

29. What are the two types of CDNs?

There are two types of CDNs:

·         Microsoft – Load jQuery from Ajax

·         CDN Google – Load jQuery from Google libraries API

 

30. Which sign is used as a shortcut for jQuery?

Dollar ($) sign is used as a shortcut for jQuery.

 

31. Is jQuery is a client or server scripting?

jQuery is a client scripting.

 

32. What is the script build up by jQuery?

jQuery is a Javascript file and it is single javascriptfile that contains common DOM, event effects and Ajax functions.

 

33. How can we debug jQuery?

There are two ways to debug jQuery:

Debugger keyword

Add the debugger to the line from where we have to start debugging and then run Visual Studio in Debug mode with F5 function key.

Insert a break point after attaching the process

 

34. What are all the ways to include jQuery in a page?

Following are the ways to include jQuery in a page:

·         Local copy inside script tag

·         Remote copy of jQuery.com

·         Remote copy of Ajax API

·         Local copy of script manager control

·         Embedded script using client script object

 

35. What is the use of jQuery.ajax method ()?jQuery.ajax method is used for

asynchronous HTTP requests.

 

36. Where can we download JQuery?

jQuery javascript can be downloaded from jQuery official website – www.jquery.com

 

37. Is jQuery is a replacement of JavaScript?

No, jQuery is not a replacement of JavaScript.

 

38. What is called chaining?

Chaining is used to connect multiple events and functions in a selector.

 

39. What are the advantages of jQuery?

Following are the advantages of jQuery:

Just a JavaScript enhancement Coding is simple, clear, reusable Removal of writing more complex conditions and loops

 

40. Whether C# code behind can be called from jQuery?

Yes, we can call C# code behind from jQuery.

 

41. What is the use of jQuery.data() method?

jQuery data method is used to associate data with DOM nodes and JavaScript objects. This method will make a code very concise and neat.

 

42. What is the difference between onload() anddocument.ready()?

In a page, we can have only one onload function but we can have more than one document.readyfunction. Document.ready function is called when DOM is loaded but onload function is called when DOM and images are loaded on the page.

 

43. What is the use of jQuery each function?

jQuery each function is used to loop through each and every element of the target jQuery object. It is also useful for multi element DOM, looping arrays and object properties.

 

44. How method can be called inside code behind using jQuery?

$.ajax can be called and by declaring WebMethodinside code behind using jQuery.

45. Which is the fastest selector in jQuery?

ID and Element are the fastest selectors in jQuery.

 

46. What is the slowest selector in jQuery?

Class selectors are the slowest selectors in jQuery.

 

47. Where jQuery code is getting executed?

jQuery code is getting executed on a client browser.

 

48. What is the method used to define the specific character in place of $ sign?

‘NoConflict’ method is used to reference a jQuery and save it in a variable. That variable can be used instead of Sign.

 

49. Why jQuery is better than JavaScript?

jQuery is a library used for developing Ajax application and it helps to write the code clean and concise. It also handles events, animation and Ajax support applications.

 

50. What are the types of selectors in jQuery?

There are three types of selectors in jQuery:

·         CSS Selector

·         XPath Selector

·         Custom Selector

JavaScript Interview Questions

JavaScript Interview Questions

1. What is JavaScript?

JavaScript is a client-side scripting language that can be inserted into HTML pages and is understood by web browsers.

 

2. Enumerate the differences between Java and JavaScript?

Java is a complete programming language. In contrast, JavaScript is a coded program that can be introduced to HTML pages. These two languages are not at all inter-dependent and are designed for the different intent.  Java is an object - oriented programming (OOPS) or structured programming language like C++ or C whereas JavaScript is a client-side scripting language and it is said to be unstructured programming.

 

3. What are JavaScript types?

Following are the JavaScript types:

·         Number

·         String

·         Boolean

·         Function

·         Object

·         Null

·         Undefined

 

4. What is the use of isNaN function?

isNan function returns true if the argument is not a number otherwise it is false.

 

5. Between JavaScript and an ASP script, which is faster?

JavaScript is faster. JavaScript is a client-side language and thus it does not need the assistance of the web server to execute. On the other hand, ASP is a server-side language and hence is always slower than JavaScript.

 

6. What is negative infinity?

Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero.

 

7. Is it possible to break JavaScript Code into several lines?

Breaking within a string statement can be done by the use of a backslash, ‘\’, at the end of the first line

Example: [crayon-5460b64160335252603799/] And if you change to a new line when not within a string statement, then javaScript ignores break in line.

Example: [crayon-5460b64160348620793456/] Theabove code is perfectly fine, though not advisable as it hampers debugging.

 

8. Which company developed JavaScript?

Netscape is the software company who developed JavaScript.

 

9. What are undeclared and undefined variables?

Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.

Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.

 

10. Write the code for adding new elements dynamically?

 [crayon-5460b6416034b673352114/]

 

11. What are global variables? How are these variable declared and what are the problems associated with using them?

Global variables are those that are available throughout the length of the code, that is, these have no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared.

Example:

// Declare a global globalVariable = "Test";

The problems that are faced by using global variables are the clash of variable names of local and global scope. Also, it is difficult to debug and test the code that relies on global variables.

 

12. What is a prompt box?

A prompt box is a box which allows the user to enter input by providing a text box.  Label and box will be provided to enter the text or number.

 

13. What is ‘this’ keyword in JavaScript?

‘This’ keyword is used to point at the current object in the code. For instance: If the code is presently at an object created by the help of the ‘new’ keyword, then ‘this’ keyword will point to the object being created.

 

14. Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout,setInterval and clearInterval.

The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. The clearInterval(id) function instructs the timer to stop.

Timers are operated within a single thread, and thus events might queue up, waiting to be executed.

 

15. Which symbol is used for comments inJavascript?

// for Single line comments and

/*   Multi

Line

Comment

*/

 

16. What is the difference between ViewState andSessionState?

‘ViewState’ is specific to a page in a session.

‘SessionState’ is specific to user specific data that can be accessed across all pages in the web application.

 

17. What is === operator?

=== is called as strict equality operator which returns true when the two operands are having the same value without any type conversion.

 

18. Name all the datatypes available in javascript?

The different datatypes are:

·         Number

·         String

·         Boolean

·         Function

·         Object

·         Null

·         Undefined

 

19. What are "undeclared" and "undefined" variables?

Undeclared variables are declared during run time and those variables cannot be declared in the program.

Undefined variables are the variables that are declared before assigning value to the program.

 

20. How can the style/class of an element be changed?

It can be done in the following way: [crayon-5460b6416034f421097026/] or [crayon-5460b64160352176208423/]

 

21. Define the occurrence of negative infinity in JavaScript?

Negative infinity is a special number which comes up when a negative number is divided by zero.

 

 22. What are all the looping structures in JavaScript?

Following are looping structures in Javascript:

·         For

·         While

·         do-while loops

 

23. What is called Variable typing in Javascript?

Variable typing is used to assign a number to a variable and the same variable can be assigned

to a string.

Example [crayon-5460b64160355238239348/] This is called variable typing.

 

24. How can you convert the string of any base to integer in JavaScript?

The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given string.

In order to convert 4F (of base 16) to integer, the code used will be - [crayon-5460b64160357815161658/]

 

25. Explain the difference between “==” and “===”?

“==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.

 

26. What would be the result of 3+2+"7"?

Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57.

 

27. How can we append a value to an array?

Array value can be appended by arr[arr.length] = value;

 

28. What do mean by NULL in Javascript?

The NULL value is used to represent no value or no object.  It implies no object or null string, no validboolean value, no number and no array object.

 

29. What is the function of delete operator?

The functionality of delete operator is used to delete all variables and objects in a program but it cannot delete variables declared with VAR keyword.

 

30. What is an undefined value in JavaScript?

Undefined value means the

·         Variable used in the code doesn’t exist

·         Variable is not assigned to any value

·         Property doesn’t exist

 

31. What are all the types of Pop up boxes available in JavaScript?

·         Alert

·         Confirm and

·         Prompt

 

32. What is the use of Void(0)?

Void(0) is used to prevent the page from refreshing and parameter "zero" is passed while calling.

Void(0) is used to call another method without refreshing the page.

 

33. How can a page be forced to load another page in JavaScript?

The following code has to be inserted to achieve the desired effect: [crayon-5460b6416035b636060084/]

 

34. What is the data type of variables of in JavaScript?

All variables in the JavaScript are object data types.

 

35. What is the difference between an alert box and a confirmation box?

An alert box displays only one button which is the OK button.

But a Confirmation box displays two buttons namely OK and cancel.

 

36. What are escape characters?

Escape characters (Backslash) is used when working with special characters like single quotes, double quotes, apostrophes and ampersands. Place backslash before the characters to make it display.

Example: [crayon-5460b6416035d308483037/]

 

37. What are JavaScript Cookies?

Cookies are the small test files stored in a computer and it gets created when the user visits the websites to store information that they need. Example could be User Name details and shopping cart information from the previous visits.

 

38. What are the looping structures used in JavaScript?

·         For

·         While

·         Do---while

·         For each

 

39. Whether JavaScript has concept level scope?

No. JavaScript does not have concept level scope. The variable declared inside the function has scope inside the function.

 

40. What is the use of delete operator in JavaScript?

The delete operator is used to delete all the variables used in the program. It does not delete variables declared with the VAR keyword.

 

41. What is break and continue statements?

Break statement exits from the current loop.

Continue statement continues with next statement of the loop.

 

42. What are the two basic groups of dataypes in JavaScript?

They are as –

Primitive Reference types.

Primitive types are number and Boolean data types. Reference types are more complex types like strings and dates.

 

43. How generic objects can be created?

Generic objects can be created as: [crayon-5460b64160360650861559/]

 

44. What is the use of type of operator?

‘Typeof’ is an operator which is used to return a string description of the type of a variable.

 

45. Which keywords are used to handle exceptions?

Try… Catch---finally is used to handle exceptions in the JavaScript [crayon-5460b6416036a084662851/]

 

46. Which keyword is used to print the text in the screen?

document.write(“Welcome”) is used to print the text – Welcome in the screen.

 

47. What is the use of blur function?

Blur function is used to remove the focus from the specified object.

 

48. What is variable typing?

Variable typing is used to assign a number to a variable and then assign string to the same variable. Example is as follows: [crayon-5460b6416036d993767509/]

 

49. How to find operating system in the client machine using JavaScript?

The ‘Navigator.appversion’ is used to find the name of the operating system in the client machine.

 

50. What are the different types of errors in JavaScript?

There are three types of errors:

·         Load time errors: Errors which come up when loading a web page like improper syntax errors are known as Load time errors and it generates the errors dynamically.

·         Run time errors: Errors that come due to misuse of the command inside the HTML language.

·         Logical Errors: These are the errors that occur due to the bad logic performed on a function which is having different operation.

 

51. What is the use of Push method in JavaScript?

The push method is used to add or append one or more elements to the end of an Array. Using this method, we can append multiple elements by passing multiple arguments

 

52. What is unshift method in JavaScript?

Unshift method is like push method which works at the beginning of the array.  This method is used to prepend one or more elements to the beginning of the array.

HTML Interview Questions

HTML Interview Questions

1) What is HTML?

HTML is short for HyperText Markup Language, and is the language of the World Wide Web. It is the standard text formatting language used for creating and displaying pages on the Web. HTML documents are made up of two things: the content and the tags that formats it for proper display on pages.

 

2) What are tags?

Content is placed in between HTML tags 0in order to properly format it. It makes use of the less than symbol (). A slash symbol is also used as a closing tag. For example: [crayon-5460b56aaa96e528239727/]

 

3) Do all HTML tags come in pair?

No, there are single HTML tags that does not need a closing tag. Examples are the

tag and tags.

 

4) What are some of the common lists that can be used when designing a page?

You can insert any or a combination of the following list types:

-          ordered list

-          unordered list

-          definition list

-          menu list

-          directory list Each of this list types makes use of a different tag set to compose

 

5) How do you insert a comment in html?

Comments in html begins with “”. For example: [crayon-5460b56aaa976937045998/]

 

6) Do all character entities display properly on all systems?

No, there are some character entities that cannot be displayed when the operating system that the browser is running on does not support the characters. When that happens, these characters are displayed as boxes.

 

7) What is image map?

Image map lets you link to many different web pages using a single image. You can define shapes in images that you want to make part of an image mapping.

 

8 ) What is the advantage of collapsing white space?

White spaces are blank sequence of space characters, which is actually treated as a single space character in html. Because the browser collapses multiple space into a single space, you can indent lines of text without worrying about multiple spaces. This enables you to organize the html code into a much more readable format.

 

9) Can attribute values be set to anything or are there specific values that they accept?

Some attribute values can be set to only predefined values. Other attributes can accept any numerical value that represents the number of pixels for a size.

 

10) How do you insert a copyright symbol on a browser page?

To insert the copyright symbol, you need to type © or & #169; in an HTML file.

 

11) How do you create links to sections within the same page?

Links can be created using the  tag, with referencing through the use of the number (#) symbol. For example, you can have one line as BACK TO TOP, which would result in the words “BACK TO TOP” appearing on the webpage and links to a bookmark named topmost. You then create a separate tag command like  somewhere on the top of the same webpage so that the user will be linked to that spot when he clicked on “BACK TO TOP”.

 

12) Is there any way to keep list elements straight in an html file?

By using indents, you can keep the list elements straight. If you indent each subnested list in further than the parent list that contains it, you can at a glance determine the various lists and the elements that it contains.

 

13) If you see a web address on a magazine, to which web page does it point?

Every web page on the web can have a separate web address. Most of these addresses are relative to the top-most web page. The published web address that appears within magazines typically points this top-most page. From this top level page, you can access all other pages within the web site.

 

14) What is the use of using alternative text in image mapping?

When you use image maps, it can easily become confusing and difficult to determine which hotspots corresponds with which links. Using alternative text lets you put a descriptive text on each hotspot link.

 

15) Do older html files work on newer browsers?

Yes, older html files are compliant to the HTML standard. Most older files work on the newer browsers, though some features may not work.

 

16) Does a hyperlink apply to text only?

No, hyperlinks can be used on text as well as images. That means you can convert an image into a link that will allow user to link to another page when clicked. Just surround the image within the … tag combinations.

17) If the user’s operating system does not support the needed character, how can the symbol be represented?

In cases wherein their operating system does not support a particular character, it is still possible to display that character by showing it as an image instead.

 

18) How do you change the number type in the middle of a list?

The tag includes two attributes – type and value. The type attribute can be used to change the numbering type for any list item. The value attribute can change the number index.

 

19) What are style sheets?

Style sheets enable you to build consistent, transportable, and well-defined style templates. These templates can be linked to several different web pages, making it easy to maintain and change the look and feel of all the web pages within a site.

 

20) What bullet types are available?

With ordered lists, you can select to use a number of different list types including alphabetical and Roman numerals. The type attribute for unordered lists can be set to disc, square, or circle.

 

21) How do you create multicolored text in a webpage?

To create text with different colors, use the … tags for every character that you want to apply a color. You can use this tag combination as many times as needed, surrounding a single character or an entire word.

 

22) Why are there both numerical and named character entity values?

The numerical values are taken from the ASCII values for the various characters, but these can be difficult to remember. Because of this, named character entity values were created to make it easier for web page designers to use.

 

23) Write a HTML table tag sequence that outputs the following: 50 pcs 100 500 10 pcs 5 50

Answer: [crayon-5460b56aaa97b118168849/]

 

24) What is the advantage of grouping several checkboxes together?

Although checkboxes don’t affect one another, grouping checkboxes together helps to organize them. Checkbox buttons can have their own name and do not need to belong to a group. A single web page can have many different groups of checkboxes.

 

25) What will happen if you overlap sets of tags?

If two sets of html tags are overlapped, only the first tag will be recognized. You will recognize this problem when the text does not display properly on the browser screen.

 

26) What are applets?

Applets are small programs that can be embedded within web pages to perform some specific functionality, such as computations, animations, and information processing. Applets are written using the Java language.

 

27) What if there is no text between the tags or if a text was omitted by mistake? Will it affect the display of the html file?

If there is no text between the tags, then there is nothing to format, so no formatting will appear. Some tags, especially tags without a closing tag like the

tag, do not require any text between them.

 

28) Is it possible to set specific colors for table borders?

You can specify a border color using style sheets, but the colors for a table that does not use style sheets will be the same as the text color.

 

29) How do you create a link that will connect to another web page when clicked?

To create hyperlinks, or links that connect to another web page, use the href tag. The general format for this is: text Replace “site” with the actual page urlthat is supposed to be linked to when the text is clicked.

 

30) What other ways can be used to align images and wrap text?

Tables can be used to position text and images. Another useful way to wrap text around an image is to use style sheets.

 

31) Can a single text link point to two different web pages?

No. The  tag can accept only a single href attribute, and it can point to only a single web page.

 

32) What is the difference between the directory and menu lists and the unordered list?

The key differences is that the directory and menu lists do not include attributes for changing the bullet style.

 

33) Can you change the color of bullets?

The bullet color is always the same as that of the first character in the list litem. If you surround the and the first character with a set of  tags with the color attribute set, the bullet color and the first character will be a different color from the text.

34) What are the limits of the text field size?

The default size for a text field is around 13 characters, but if you include the size attribute, you can set the size value to be as low as 1. The maximum size value will be determined by the browser width. If the size attribute is set to 0, the size will be set to the default size of 13 characters.

HTML5 Interview Questions

HTML5 Interview Questions

1. What is the use of Canvas Element in HTML5? 

HTML5 Canvas element can be used to draw graphics images on a web page by using javascript.

2. Can you give an example of Canvas element how it can be used?

<canvas id=“DGTCanvas” width=“500″ height=“400″>
</canvas>
<script type=“text/javascript”>
varDGTCanvas=document.getElementById(“DGTCanvas”);
var DGTText=DGTCanvas.getContext(“2d”);
DGTText.fillStyle=“#82345c”;
DGTText.fillRect(0,0,150,75);
</script>

This book is far better than any other learning material. It has very basic information that includes both HTML5 and CSS3 with sample code and comprehensive examples.

3. What is the purpose of HTML5 versus XHTML?

HTML5 is the next version of HTML 4.01, XHTML 1.0 and DOM Level 2 HTML. It aims to reduce the need for proprietary plug-in-based rich internet application (RIA) technologies such as Adobe Flash, Microsoft Silverlight, Apache Pivot, and Sun JavaFX. Instead of using those plugins, it enables browser to serve elements such as video and audio without any additional requirements on the client machine.

 4. What is the difference between HTML and HTML5 ?

HTML5 is nothing more then upgraded version of HTML where in HTML5 supports the innovative features such as Video, Audio/mp3, date select function , placeholder , Canvas, 2D/3D Graphics, Local SQL Database added so that no need to do external plugin like Flash player or other libraryelemenents.

5. WHAT are some other advantages of HTML5?

a) Cleaner markup than earlier versions of HTML
b) Additional semantics of new elements like <header>, <nav>, and <time>
c) New form input types and attributes that will (and in Opera’s case, do) take the hassle out of scripting forms.

6. What is the <!DOCTYPE>? Is it mandatory to use in HTML5?

The <!DOCTYPE> is an instruction to the web browser about what version of HTML the page is written in. The <!DOCTYPE> tag does not have an end tag. It is not case sensitive.

The <!DOCTYPE> declaration must be the very first thing in HTML5 document, before the <html> tag.  As In HTML 4.01, all <! DOCTYPE > declarations require a reference to a Document Type Definition (DTD), because HTML 4.01 was based on Standard Generalized Markup Language (SGML). WHERE AS HTML5 is not based on SGML, and therefore does not require a reference to a Document Type Definition (DTD).

7. What are the New Media Elements in HTML5?

New Media Elements in HTML5 are :

Tag

Description

<audio>

For multimedia content, sounds, music or other audio streams

<video>

For video content, such as a movie clip or other video streams

<source>

For media resources for media elements, defined inside video or audio
elements

<embed>

For embedded content, such as a plug-in

<track>

For text tracks used inmediaplayers

8. What is the major improvement with HTML5 in reference to Flash?

Flash is not supported by major mobile devices such as iPad, iPhone and universal android applications. Those mobile devices have lack of support for installing flash plugins. HTML5 is supported by all the devices, apps and browser including Apple and Android products. Compared to Flash, HTML5 is very secured and protected. That eliminates major concerns that we have seen with Flash.

10. What is the sessionStorage Object in html5 ? How you can create and access that?

The HTML5 sessionStorage object stores the data for one session. The data is deleted when the user closes the browser window. We can create and access asessionStorage, created “name” as session

<script type=“text/javascript”>
sessionStorage.name=“DGTECH”;
document.write(sessionStorage.name);
</script>

 11. What is the full form of URI, URL, URN?

URI - Uniform Resource Identifier 
URL - Uniform Resource Locator 
URN - Uniform Resource Name

12. Write code for a html table that will have one row and one column?

<table>

     <tr>

          <td>

         </td>

    </tr>

</table>

 

13.Difference between GET and POST Metods

Difference Between GET and POST methods 

GET: 
1) Data is appended to the URL. 
2) Data is not secret. 
3) It is a single call system 
4) Maximum data that can be sent is 256. 
5) Data transmission is faster 
6) This is the default method for many browsers 

POST: 
1) Data is appended to the URL. 
2) Data is Secret 
3) It is a two call system. 
4) There is no Limit on the amount of data.That is characters any amount of data can be sent. 
5) Data transmission is comparatively slow. 
6) No default and should be Explicitly specified.

14.Why to specify the alt value in the img tag?

alt stands for alternate this means that for some reason if image can't be loaded on the page, the alt value will be displayed.

<img src="myimage.jpg" alt="this is my photo" title="click to go to my page" />

In the above code snippet when myimage.jpg is available on the web server, the image will be displayed and mouse ever on the image will show "click to go to my page" but in case myimage.jpg is not available on the server or by some reason itcould't be rendered on the page, alt value (this is my photo) will be displayed in place of image. This hints the user that the picture that couldn't be loaded was my photo.

15. How to add javascript file reference in the web page?

We can use <script> tag to refer the .js file available on the server, we can not only refer only those file that are on our server but we cal also any .js file that is available on other server (on other domain.

<script src="/include/myjscode.js" type="text/javascript"></script>

It is always suggested to place the script tag inside <head></head>

16. How to display the web page icon in the browser?

By placing the link tag inside the <head></head and specify rel value as "shortcut icon", you can display the page icon in the browser.

<link rel="shortcut icon" href="/images/myicon.gif" />

Here, you can either specify .gif, .jpg or .ico file, however many browser only support .ico file not .gif or .jpg file.

17. How to refer the .css file in the web page?

 

To refer .css file in the web page, use <link> tag. Generally it is suggested to keep this inside the <head></head> tag.

<link href="/css/mystyle.css" type="text/css"rel="stylesheet" />

Notice that the type attribute value should be "text/css" and rel attribute value should be "stylesheet".

18. How to write bulleted point in HTML?

To write bulleted point, use <li> under <ul> like following.

    <ul>

        <li>Point 1</li>

        <li>Point 2</li>

        <li>Point 3</li>

    </ul>

In this case Point 1, Point 2 and Point 3 will appear as bulleted point.

19. How to display numbered list in HTML?

To display numbered list, use <li> under <ol> tag like below

 <ol>

     <li>Point 1</li>

     <li>Point 2</li>

  </ol>

 

20. How to create a DropDown list box?

To create a dropdown list box in HTML, write following code

  <select name="drop1" id="drop1">

                    <option value="1">item 1</option>

                    <option value="2">item 2</option>

                    <option value="0">All</option>

  </select>

This will create a dropdown with two list item "item 1" and "item 2".

21. How to create a ListBox in HTML?

To create a list box, write following code

<select name="drop1" id="Select1" size="4" multiple="multiple">

    <option value="1">item 1</option>

    <option value="2">item 2</option>

    <option value="3">item 3</option>

    <option value="4">item 4</option>

    <option value="0">All</option>

</select>

 

This will create a listbox with 5 items. As multipleattribute value is specified as ="multiple" so it gives ability to select more than one item from the box by holding ctrl key or by dragging through items from the mouse.

22. Should we use table tag to design the layout of the webpage?

No, <table> tag is made for rendering the data in tabular format not to design the layout of the webpage, however this is massively used for the designer because its easy to use. 

To design the layout we should use <div> and/or <span> along with css classes.

23. What is the code to write bulleted and numbered list in HTML.

To write bulleted list in the HTML, write following code:

<ul>

  <li>fdasfadsf asdf</li>

  <li>sfdafasdf</li>

  <li>fdsafasfsa</li>

  <li>fdsafsda</li>

</ul>

To write numbered list in the HTML, write following code:

<ol>

  <li>fdasfadsf asdf</li>

  <li>sfdafasdf</li>

  <li>fdsafasfsa</li>

  <li>fdsafsda</li>

</ol>

Notice the difference is only <ul> and <ol>. In the bulleted list, we need to use <ul> tag and in the numbered list we need to use <ol> tag.

24. What is <!DOCTYPE> defines in HTML?

Doctype defines as "document type declaration" (DTD). 

All HTML pages should contain a <!DOCTYPE> declaration to define which HTML version we are using in our page. it gives important instruction to web browser about page's HTML version type. It also allows web validator to check the syntax of page.

25. How FontSize and Font Size is differ in HTML?

font size is an attribute that we used in font tag. 
Ex : <font size="5"> use in font tag. 

Where as font-size is an style property used for controls. 
Ex : Font-Size="Small" use for style property For Controls.

26. How to forbid autocomplete for a form ?

 

use autocomplete="off"

27. What is the user of alt property in <img> tag?

The use of "alt" property of <img> tag is to display the alt value in case browser is unable to load the image so that the end user can understand what kind of image was actually there on the page that couldn't be loaded.

28. What is the use of title property of <img> tag?

The title property of <img> tag is used to describe about the image. The value of title property is displayed when the end user mouse over the image.

29. What should be the href property value of anchor tag in case we want to handle the click event

The href property of anchor tag should be "javascript:void(0)" when we want to handle the click event of the anchor tag. Many people keephref="#" that jump the screen to top when the link is clicked.

<a id="closeLink"  href="javascript:void(0)"onclick="Clicked()" title="Whatever">Whatever link</a>

In other way we can also write like this

<a id="closeLink"  href="javascript:Clicked()" title="Whatever">Whatever link</a>

30 What is SPA ?

Single Page application(SPA) is a web application or web site that fits on a single web page which provides a more fluid UX akin to a desktop application by loading all necessary code (using HTML, JavaScript, and CSS) with single page Load.

 

CSS3 Interview Questions

CSS3 Interview Questions

1. How to write conditional statement in CSS?

Following is the example of conditional statement in CSS.

 <head>

        <style type="text/css">

           body

            {

                color:blue;

            }

        </style>

        <!--[if IE 7]>

        <style type="text/css">

        body {

            background-color:red;

        }

        </style>

        <![endif]-->

 </head>

If this code will run in IE7 browser, the background color of the page will be red, for other browser it will be default color (white).

2. How to write styles for all html elements of the same type?

If we want to maintain uniformity in the look and feel of all same type of elements on the page, we can write CSS class with the element name.eg. 

If we want to change the look and feel of all table and h1 element on the page, we can write like this.

table

{

                    font-size:10pt;

        font-family: Arial;

}

h1

{

    font-size:14pt;

    padding-left:5px;

    margin:0px;

    color:#094BBB;

}

The first class "table" will apply to all the tables on the page and second class "h1" will apply to all the h1 element of the page. 

Note that the name of the class is not prefixed withthe . (dot) as it happens with normal css class name.

3. What are the possible values of the "Position" attributes?

The possible value of the "Position" attributes are 

absolute 
fixed 
inherit 
relative 
static 

By default, relative value is considered.

4. How to display a link without underline and display underline when mouseover on the link using CSS?

Write following css class.

a

{

    text-decoration:none;

}
a:hover

{

    text-decoration:underline;

}

The first class will force all anchor tag (link)to not display any docoration (underline) and second class will force all anchor tag (link) to display text decoration as underline when mouse over it (ie. display underline when mouse over).

5. How to float the image left side and let the page content fill right side and bottom in CSS?

 

Wrap the div element with fload:left style.

<div style="float: left">

<img src="fsdaf.gif" />Your contents goes here.

</div>

To reverse, ie float the image in the right side and let the content fill the space at the left and further down, specify float:right style.

6. How to line break in CSS?

Use display:block style with span.

<span style="display:block;" />

7. How to page break after an html element in CSS?

Use following code snippet

<p style="page-break-after: always">Place your text</p>

After above code, the rest content will appear in the next page. (It will not be visible as next page in browser but on the printer and in Print Preview, you will see them as next page)

8. State some limitations of style sheets?

Style sheets do have its own share of limitations some of them are as follows: - 
1) Inconsistent browser support 
2) Vertical control limitations 
3) Margin collapsing, float containment, control of element shapes, etc 
4) Lack of column declaration and variables are some of the limitations present in CSS.

9. How do I center block-elements with CSS1?

There are two ways of centering block level elements: 

1. By setting the properties margin-left and margin-right to auto and width to some explicit value: 

BODY {width: 30em; background: cyan;} 
P {width: 22em; margin-left: auto; margin-right: auto} 

In this case, the left and right margins will each be four ems wide, since they equally split up the eight ems left over from (30em - 22em). Note that it was not necessary to set an explicit width for the BODY element; it was done here to keep the math clean. 

Another example: 

TABLE {margin-left: auto; margin-right: auto; width:400px;} 
In most legacy browsers, a table's width is by default determined by its content. In CSS-conformant browsers, the complete width of any element (including tables) defaults to the full width of its parent element's content area. As browser become more conformant, authors will need to be aware of the potential impact on their designs.

10. What does CSS stand for?

NOTE: This is objective type question, Please click question title for correct answer.

11. Explain inline, embedded and external stylesheets .

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 <link> tag. The <link> tag goes inside the head section: 
<head> 
<link rel="stylesheet" type="text/css"href="mystyle.css" /> 
</head> 

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 <style> tag, like this: 
<head> 
<style type="text/css"> 
hr {color:sienna} 
p {margin-left:20px} 
body {background-image:url("images/back40.gif")} 
</style> 
</head> 

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: 
<p style="color:sienna;margin-left:20px">This is a paragraph.</p>

12. What are the values of "Position" attribute in CSS?

Possible values are 
static, relative, absolute, fixed, inherit

13. What is the default value of "position" attribute in css?

Default value is "static".

Display and visibility properties are used to hide and show elements in any page. Then how they are different from each other?

As said Both the properties are used to hide and show elements but they are different in the way they both work. visibility property, set to hidden will still occupy the space in the layout but display:none does not take up the space in the page.

14. Can you specify more than one css class for any HTML element?

Yes, you can. Just provide a space between both the class names. 

like..

<div class="class1 class2">

</div>

 

15. What is the difference between specifying cssclass with # and .? i.e. #Class1 or .Class1?

Stylesheeet class declared with # applies to items which have same Id value as of the class name. 

like

#div1

{

   font-weight:bold;

}

<div id="div1">Styled Container</div>

Where css class declared with . can be used for any html element.

.class1

      {

         position:relative;

         left:50px;

      }

<div class="class1">Styled Container</div>

Cascading Style Sheets (CSS) is not case sensitve. However, font families, URLs to images, and other direct references with the style sheet may be. 

If your page uses an XML declaration and an XHTML DOCTYPE then the CSS selectors will be case-sensitive for some browsers, if your page uses a HTML DOCTYPE then your CSS selectors will be case-insensitive. 

It is a good idea to avoid naming classes where the only difference is the case, for example: 
div.myclass { ...} 
div.myClass { ... }

16. What is embedded style? How to link?

The HEAD area, where the TITLE and META tags are found, is also used to store CSS commands. 
These are called embedded CSS. Any embedded CSS command will over-ride an external CSS command of the same tag. Embedded commands are more specific to the page. 

Embedded CSS codes are placed within the HEAD area of the page code. That is anywhere after the <HEAD> tag and before the </HEAD> tag. NOT in the HEAD tag itself. 

<style type="text/css" media=screen> 
<!-- 
p {font-family: georgia, serif; font-size: x-small;} 
hr {color: #ff9900; height: 1px } 
a:hover {color: #ff0000; text-decoration: none} 
--> 
</style> 

Now, whenever any of those elements are used within the body of the document, they will be formatted as instructed in the above style sheet.

17. What is CSS rule 'ruleset'?

There are two types of CSS rules: ruleset and at-rule.Ruleset identifies selector or selectors and declares style which is to be attached to that selector or selectors. For example P {text-indent: 10pt} is a CSS rule. CSS rulesets consist of two parts: selector, e.g. P and declaration, e.g. {text-indent: 10pt}. 

P {text-indent: 10pt} - CSS rule (ruleset) 
{text-indent: 10pt} - CSS declaration 
text-indent - CSS property 
10pt - CSS value

18. What is ID selector?

ID selector is an individually identified (named) selector to which a specific style is declared. Using the ID attribute the declared style can then be associated with one and only one HTML element per document as to differentiate it from all other elements. ID selectors are created by a character # followed by the selector's name. 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. 

#abc123 {color: red; background: black} 

<P ID=abc123>This and only this element can be identified as abc123 </P>

19. How to write conditional statement in CSS?

Following is the example of conditional statement in CSS.

 <head>

        <style type="text/css">

           body

            {

                color:blue;

            }

        </style>

        <!--[if IE 7]>

        <style type="text/css">

        body {

            background-color:red;

        }

        </style>

        <![endif]-->

 </head>

If this code will run in IE7 browser, the background color of the page will be red, for other browser it will be default color (white).

20. How to write styles for all html elements of the same type?

If we want to maintain uniformity in the look and feel of all same type of elements on the page, we can write CSS class with the element name.eg. 

If we want to change the look and feel of all table and h1 element on the page, we can write like this.

table

{

                    font-size:10pt;

        font-family: Arial;

}

h1

{

    font-size:14pt;

    padding-left:5px;

    margin:0px;

    color:#094BBB;

}

The first class "table" will apply to all the tables on the page and second class "h1" will apply to all the h1 element of the page. 

Note that the name of the class is not prefixed withthe . (dot) as it happens with normal css class name.

21. What are the possible values of the "Position" attributes?

The possible value of the "Position" attributes are 

absolute 
fixed 
inherit 
relative 
static 

By default, relative value is considered.

22. How to display a link without underline and display underline when mouseover on the link using CSS?

Write following css class.

a

{

    text-decoration:none;

}

a:hover

{

    text-decoration:underline;

}

The first class will force all anchor tag (link)to not display any docoration (underline) and second class will force all anchor tag (link) to display text decoration as underline when mouse over it (ie. display underline when mouse over).

23. How to float the image left side and let the page content fill right side and bottom in CSS?

Wrap the div element with fload:left style.

<div style="float: left">

<img src="fsdaf.gif" />Your contents goes here.

</div>

To reverse, ie float the image in the right side and let the content fill the space at the left and further down, specify float:right style.

24. How to line break in CSS?

Use display:block style with span.

<span style="display:block;" />

 

25. How to page break after an html element in CSS?

Use following code snippet

<p style="page-break-after: always">Place your text</p>

After above code, the rest content will appear in the next page. (It will not be visible as next page in browser but on the printer and in Print Preview, you will see them as next page)

26. State some limitations of style sheets?

Style sheets do have its own share of limitations some of them are as follows: - 
1) Inconsistent browser support 
2) Vertical control limitations 
3) Margin collapsing, float containment, control of element shapes, etc 
4) Lack of column declaration and variables are some of the limitations present in CSS.

27. How do I center block-elements with CSS1?

There are two ways of centering block level elements: 

1. By setting the properties margin-left and margin-right to auto and width to some explicit value: 

BODY {width: 30em; background: cyan;} 
P {width: 22em; margin-left: auto; margin-right: auto} 

In this case, the left and right margins will each be four ems wide, since they equally split up the eight ems left over from (30em - 22em). Note that it was not necessary to set an explicit width for the BODY element; it was done here to keep the math clean. 

Another example: 

TABLE {margin-left: auto; margin-right: auto; width:400px;} 
In most legacy browsers, a table's width is by default determined by its content. In CSS-conformant browsers, the complete width of any element (including tables) defaults to the full width of its parent element's content area. As browser become more conformant, authors will need to be aware of the potential impact on their designs.

28. What does CSS stand for?

NOTE: This is objective type question, Please click question title for correct answer.

29. Explain inline, embedded and external stylesheets .

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 <link> tag. The <link> tag goes inside the head section: 
<head> 
<link rel="stylesheet" type="text/css"href="mystyle.css" /> 
</head> 

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 <style> tag, like this: 
<head> 
<style type="text/css"> 
hr {color:sienna} 
p {margin-left:20px} 
body {background-image:url("images/back40.gif")} 
</style> 
</head> 

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: 
<p style="color:sienna;margin-left:20px">This is a paragraph.</p>

What are the values of "Position" attribute in CSS?

 

Possible values are 
static, relative, absolute, fixed, inherit

30. What is the default value of "position" attribute in css?

Default value is "static".

Display and visibility properties are used to hide and show elements in any page. Then how they are different from each other?

As said Both the properties are used to hide and show elements but they are different in the way they both work. visibility property, set to hidden will still occupy the space in the layout but display:none does not take up the space in the page.

31. Can you specify more than one css class for any HTML element?

Yes, you can. Just provide a space between both the class names. 

like..

<div class="class1 class2">

</div>

 

32. What is the difference between specifying cssclass with # and .? i.e. #Class1 or .Class1?

Stylesheeet class declared with # applies to items which have same Id value as of the class name. 

like

#div1

{

   font-weight:bold;

}

<div id="div1">Styled Container</div>

Where css class declared with . can be used for any html element.

.class1

      {

         position:relative;

         left:50px;

      }

<div class="class1">Styled Container</div>

Cascading Style Sheets (CSS) is not case sensitve. However, font families, URLs to images, and other direct references with the style sheet may be. 

If your page uses an XML declaration and an XHTML DOCTYPE then the CSS selectors will be case-sensitive for some browsers, if your page uses a HTML DOCTYPE then your CSS selectors will be case-insensitive. 

It is a good idea to avoid naming classes where the only difference is the case, for example: 
div.myclass { ...} 
div.myClass { ... }

33. What is embedded style? How to link?

The HEAD area, where the TITLE and META tags are found, is also used to store CSS commands. 
These are called embedded CSS. Any embedded CSS command will over-ride an external CSS command of the same tag. Embedded commands are more specific to the page. 

Embedded CSS codes are placed within the HEAD area of the page code. That is anywhere after the <HEAD> tag and before the </HEAD> tag. NOT in the HEAD tag itself. 

<style type="text/css" media=screen> 
<!-- 
p {font-family: georgia, serif; font-size: x-small;} 
hr {color: #ff9900; height: 1px } 
a:hover {color: #ff0000; text-decoration: none} 
--> 
</style> 

Now, whenever any of those elements are used within the body of the document, they will be formatted as instructed in the above style sheet.

34. What is CSS rule 'ruleset'?

There are two types of CSS rules: ruleset and at-rule.Ruleset identifies selector or selectors and declares style which is to be attached to that selector or selectors. For example P {text-indent: 10pt} is a CSS rule. CSS rulesets consist of two parts: selector, e.g. P and declaration, e.g. {text-indent: 10pt}. 

P {text-indent: 10pt} - CSS rule (ruleset) 
{text-indent: 10pt} - CSS declaration 
text-indent - CSS property 
10pt - CSS value