Tuesday, 31 May 2016

ionic iOS App Publishing

ionic iOS Publishing:
If you want publish app in app store First, you need to enroll in Apple Developer Program. need to buy account with $99(yearly).
Connecting Xcode with your developer account :
After you receive your developer account, open Xcode on your Mac and go to Preferences -> Accounts and add your account to Xcode by clicking the + button on the lower left hand side, and follow the instructions:

Click on View Details when you click on view details button will get below popup

Now you can click on create button for ios distribution. then the create option will disappear and you can see below image.

Now you can click on download and then done button.
You can find the certificates in you keychain access in certificates. see below image.

                                   
All team members can create their own development certificate. Only a team agent or admin can create a distribution certificate.

Verifying Using Your Developer Account:
    1. Sign in to developer.apple.com/account, and click Certificates, IDs & Profiles.
    2. In the Certificates section of the sidebar, select Development or Production depending on the type of certificate you want to verify. The type and expiration date of the certificate should match the information that you view in Keychain Access.
Exporting and Importing Certificates and Profiles:
The export file, called a developer profile, contains the following team assets:
  • Development certificates
  • Distribution certificates
  • Provisioning profiles
You can also export selected certificates to share with other team members. In this case, the export file contains just the certificates you select.

Exporting Your Developer Profile

Because the developer profile represents your credentials to sign and submit apps to the store, Xcode encrypts and password-protects the exported file.
To export your developer account assets
  1. Choose Xcode > Preferences.
  2. Click Accounts at the top of the window.
  3.  Click the Action button (the gear icon to the right of the Delete button) in the lower-left corner, and choose Export Developer Accounts from the pop-up menu.
4. Enter a filename in the Save As field and a password in both the Password and Verify fields. The file is encrypted and password protected.
5. Click Save. The file is saved to the location you specified with a .developerprofile extension.
6. In the dialog that appears, click OK.

Exporting Selected Certificates
To export a few certificates and exclude the profiles, select the certificates in the details dialog.
To export selected certificates
    1. Choose Xcode > Preferences. 
    2. Click Accounts at the top of the window.
    3. Select the team you want to view, and click View Details. 
    4. Control-click the certificate you want to export in the Signing Identities table and choose Export from the pop-up menu.
5.Enter a filename in the Save As field and a password in both the Password and Verify fields.The file is encrypted and password protected.
6.Click Save.The file is saved to the location you specified with a .p12 extension.

Importing Your Developer Profile
You import your developer profile to restore missing private keys or when you want to switch to another Mac.

To import your developer account assets
  1. Choose Xcode > Preferences. 
  2. Click Accounts at the top of the window.
  3. Click the Action button (the gear icon) in the lower-left corner, and choose Import Developer Accounts from the pop-up menu.
4. Locate and select the file containing your developer profile, and click Open. The file should have a .developerprofile extension.
5. Enter the password you used to encrypt the file, and click OK.
6.In the dialog that appears, click OK.
Now you can able to create development profile.

Wednesday, 9 March 2016

Angularjs Interview Questions

1. What is angular js?
Ans:  Angularjs is javascript framework, used for create  a single page application.

2. Why angularjs?
Ans: HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.

3. What are the general features of angularjs
Ans:
  • AngularJS is a JavaScript framework.
  • AngularJS is a efficient framework that can create Rich Internet Applications.
  • Client side  MVC frameWork. 
  • Applications written in AngularJS are cross-browser compliant.
  • SPA (Single Page Application)
  • Supported for Web and mobiles.
  • AngularJS is open source, completely free.
  • AngularJS is a framework to build large scale Apps.
  • High performance, and easyto-maintain web applications.

4. What are the core Features Angularjs ?
Ans: 

  • Two way Data-binding: It is the automatic synchronization of data between model   and view 
  • Scope : scope is an object that refers to the application model. Every controller has an associated scope object. Scopes provide APIs ($watch) to observe model mutations.
  • Controller: These are JavaScript functions bound to a particular scope.
  • Services: AngularJS comes with several built-in services such as $http to make a XMLHttpRequests. These are singleton objects which are instantiated only once in app.
  • Filters: These select a subset of items from an array and returns a new array.
  • Directives: directives are markers on DOM elements such as elements, attributes, css, and more. These can be used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives such as ngBind, ngModel, ngApp, ngShow,ngHide, ngInit   etc.. 
  • Routing: It is concept of switching views.
  • Templates: These are the rendered view with information from the controller and model. These can be a single file (such as index.html) or multiple views in one page using partials.
  • MVC: Model View whatever ex: MVVM (Model-View-ViewModel)

5. Explain what is data binding in AngularJS ?

Automatic synchronization of data between the model and view components is referred as data binding in AngularJS.  There are two ways for data binding
two way binding {{varName}} or ng-bind="varName"
once binding {{::varName}} or ng-bind="::varName"


Sunday, 17 May 2015

HTML Best Practices

1. Start with DOCTYPE
Bad :
<html>
   <body>
      -----
   </body>
</html>
Good:

<!DOCTYPE html>
<html>
   <body>
     -----
   </body>
</html>
It helps to read and render your markup correctly.

2. Write Standards-Compliant Markup:
don't use the id attributes multiple time
don't omit the closing tags.
close the html tags properly.
Bad :

<p id="intro">properly close  the <strong> Html </p> tags .</strong>
<p id="intro">don't  omit the closing tag.
Good:

<p class="intro">properly close  the <strong> Html </strong> tags </p>
<p class="intro">don't  omit the closing tag.</p>

3. Use proper semantic elements

Bad:
<span class="heading"><strong>Heading</span></strong>
<br><br>
 some paragraph
<br><br>
Good:

<h1>Heading</h1>
<p>some paragraph</p>


4. Specify MIME type

Bad:
<link href="/pdf" rel="alternate">
<link href="/css/style.css" rel="stylesheet">
Good:

<link href="/pdf" rel="alternate" type="application/pdf">
<link href="/css/style.css" rel="stylesheet" type="text/css">


5. Write character encoding
Bad:
<head>
  <title>HTML Best Practices</title>
</head>
Good:

<head>
  <meta charset="UTF-8">
  <title>HTML Best Practices</title>
</head>


6. Avoid div structural elements

Bad:
<div class="container">
  <div class="article">
    <div class="headline">Heading</div>
  </div>
</div>
Good:

<div class="container">
  <article>
    <h1>Heading</h1>
  </article>
</div>


7. Syntax Organized

Bad:
<Aside>
<h3>heading</h3>
<H5 HIDDEN='HIDDEN'>Sub heading</H5>
<img src=sample.png alt="company logo" />
<ul>
<li>list item1</li>
<li>list item2</li>
</ul>
</ASIDE>
Good:

<aside>
  <h3>heading</h3>
  <h5 hidden>Sub heading</h5>
  <img src="sample.png" alt="company logo">
  <ul>
    <li>list item1</li>
<li>list item2</li>
  </ul>
</aside>

8. Don't use Inline Styles

Bad:
<p style="color:red">sample paragraph</p>
Good:

<p class="intro">sample paragraph</p>
keep external css
.intro {
color:red;
}

9. Keep all external style sheets inside head tag

<head>
<title>My Favorites Kinds of Corn</title>
<link rel="stylesheet" type="text/css" media="screen" href="libstyles.css" />
<link rel="stylesheet" type="text/css" media="screen" href="custom.css" />
</head>
The primary benefit is that your pages will load faster.
putting stylesheets in the HEAD allows the page to render progressively
load lib css first.
  • Use a CSS Reset
  • Placing Javascript Files at the Bottom
  • validate html in w3c 
10. Use meaning full title tags.
The <title> tag helps make a web page more meaningful and search-engine friendly. For example, the text inside the <title> tag appears in Google’s search engine results page, as well as in the user’s web browser bar and tabs.
Ex: <title>Welcome To Web Developer's Library</title>

11. Use Descriptive Meta Tags
Meta tags make your web page more meaningful for user agents like search engine spiders.

it will give the whole summary about your webpage or blog.

12. Minify CSS and JS.
we can decrease the size of the file. it means we are removing unnecessary space and comments.

13. Use right elements in right place.

14. Should use alt tag for image

15. Use modular IE fixes.
You should use conditional comments to target IE.
Ex: <!--[if IE 7]>
<link rel="stylesheet" href="css/ie-7.css" media="all">
<![endif]-->

16. Use lower case markup.

17. Validate your code.

18. Write well formatted code.

19. CSS  Exteranal files load in head tag.

20. JS External files load in body tag.

21. Choose good editor to develop the code.

22. For Beginners don't use CSS frame work better use css.

23. Use class instead of id for css, because you are losing benefits of class.

Friday, 15 May 2015

Stop writing For loops. Start using underscore

Underscore:

Underscore.js is a JavaScript library which provides utility functions for common programming tasks. It is comparable to features provided by Prototype.js and the Ruby language, but opts for a functional programming design instead of extending object prototypes.

Underscore consists of a little more than 100 functions, which fall under four main categories depending on the datatypes which they manipulate: functions for manipulating arrays, functions for manipulating objects, functions for manipulating both arrays and objects (the name of the category is "Collections") and functions for manipulating other functions. There are also two utility categories : "Utility" and "Chaining".

Example:
for example if we use javascript to achieve some functionality we need to write the  below loop
var i,result = [];
for(i = 0; i < myArray.length; i++) {
  var myObject = myArray[i];
  if(myObject.isAwesome === true) {
      result.push(myArray[i]);
  }
}

The same functionality i can achieve  with underscore.js without loop.

var result = _.filter(myArray, function(myObject) {
  return myObject.isAwesome === true;
})

Underscore Reference : (http://underscorejs.org/)

Thursday, 14 May 2015

Hybrid Mobile App Frameworks

Ionic & Angular:

The beautiful, open source front-end SDK for developing hybrid mobile apps with HTML5.

Free and open source, Ionic offers a library of mobile-optimized HTML, CSS and JS components, gestures, and tools for building highly interactive apps. Built with Sass and optimized for AngularJS

Advantages:
  • Open-source and free (under a permissive MIT license)
  • Built around Angular (Ember and Backbone not supported)
  • iOS and Android support (currently only WebKit supported devices)
  • Ionic is built to perform and behave great on the latest mobile devices. With minimal DOM manipulation, zero jQuery
  • Heavily optimized for touch devices (Ionic is focused on building native/hybrid mobile apps rather than mobile websites.)
  • Great command line utility support (Cordova users will recognize the benefit)
  • Optional Sass support
  • Supports Cordova, PhoneGap, or Trigger.io
  • Over 500 custom designed font icons MIT licensed
Built on top of the popular AngularJS framework from Google, Ionic utilizes AngularJS to provide the application structure, while Ionic itself focuses on the user interface. In other words, we see a match between the power of Angular and the beauty of Ionic UI.

Ionic provides a set of Angular directives (custom HTML elements) for it’s own components, making it as easy to use the widgets as writing a line of HTML code. In addition to directives, Ionic uses Angular’s touch recognizers, view animation logic, HTML sanitation, and asynchronous communication.
Ionic reference : ( http://ionicframework.com/)


Mobile Angular UI :

Build HTML5 create interactive mobile apps with Bootstrap3 and Angular JS

Mobile Angular UI is a mobile UI framework just like Sencha Touch or jQuery Mobile. If you know Angular JS and Twitter Bootstrap you already know it!

Main features of Mobile AngularUI
  • Bootstrap 3
  • AngularJS
  • Mobile Angular UI provides essential mobile components that are missing in Bootstrap 3: switches, overlays, sidebars, scrollable areas, absolute positioned top and bottom navbars that don't bounce on scroll.
  • AngularJS modules such as angular-route, angular-touch and angular-animate
  • Mobile Angular UI doesn’t have any jQuery dependencies, all you need are some AngularJS directives to create awesome mobile user experiences.
  • FontAwesome Icons are included by default in place of Glyphicons.
Mobile Angular UI Reference : (http://mobileangularui.com/)


Cordova/Phonegap:

Apache Cordova is a platform for building native mobile applications using HTML, CSS and JavaScript

Apache Cordova is an open-source mobile development framework.

These apps are natively installed on iOS, Android, Windows Phone, Blackberry, Tizen, Firefox OS, and others, all leveraging HTML for the user interface, CSS for layout and styling, and JavaScript for interactivity, dynamism, and interaction with native-OS functionality.

When using the Cordova APIs, an app can be built without any native code (Java, Objective-C, etc) from the app developer

And because these JavaScript APIs are consistent across multiple device platforms and built on web standards, the app should be portable to other device platforms with minimal to no changes.

a mobile developer and want to extend an application across more than one platform, without having to re-implement it with each platform's language and tool set.

a web developer and want to deploy a web app that's packaged for distribution in various app store portals

a mobile developer interested in mixing native application components with a WebView (special browser window) that can access device-level APIs, or if you want to develop a plugin interface between native and WebView components.

Cordova reference Link : (https://cordova.apache.org/)




jQuery Mobile


jQuery Mobile is an HTML5-based user interface system designed to make responsive websites and apps

jQuery Mobile is the easiest way to build sites and apps that are accessible on all popular smartphone, tablet and desktop devices.

jQuery Mobile is HTML5 markup based framework (not like Ionic Framework or Sencha Touch) inonic and scncha touch are built to work only on web kit browsers but jquery Mobile will run on pretty much anything as long it supports HTML5 standard.

jQuery Mobile offers CSS-based enhancements for common user interface elements(like classes, grid layout, responsive grid, theme)

Advantages:
  • Most commonly use, which means a lot of 3rd party information
  • Extremely easy to use, HTML5 bases, just like App Framework
  • Good official documentation.
  • Support every HTML5 browser you can think which makes it good for a desktop and mobile use
  • Excellent theme support
  • Large number of 3rd party plugins 
DisAdvantages:
  •  JQuery mobile apps are slow on mobiles.
  • Avarage UI
  • Every JQuery mobile app appears as a duplicate of the other with no customization.
  • JQuery Mobile does not offer “out of box” MVC support.
  • JQuery mobile, when combined with other mobile frameworks, becomes even more time-consuming.


jQueryMobile reference : (http://api.jquerymobile.com/)

Friday, 10 April 2015

jQuery Interview Questions And Answers.

1. What is jQuery?

Ans: jQuery is fast, lightweight and feature-rich client side JavaScript Library/Framework which helps in to traverse HTML DOM, make animations, add Ajax interaction, manipulate the page content, change the style and provide cool UI effect. It is one of the most popular client side library.

2. Why do we use jQuery?

Ans: Due to following advantages.
Easy to use and learn.
Easily expandable.
Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
Easy to use for DOM manipulation.
AJAX Capabilities.
Methods for changing or applying CSS, creating animations.
Event detection and handling.

3. How JavaScript and jQuery are different?

Ans: JavaScript is a language While jQuery is a library built in the JavaScript language.

4. Is jQuery replacement of Java Script?

Ans: No. jQuery is not a replacement of JavaScript. jQuery is a different library which is written on top of JavaScript. jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML.

5. Is jQuery a W3C standard?

Ans: No. jQuery is not a W3C standard.

6. What does dollar sign ($) means in jQuery?

Ans: Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code.
$(document).ready(function(){
});
Over here $ sign can be replaced with "jQuery" keyword.
jQuery(document).ready(function(){
});

7. Can we have multiple document.ready() function on the same page?

Ans: YES. We can have any number of document.ready() function on the same page.

8. Can we use our own specific character in the place of $ sign in jQuery?

Ans: Yes. It is possible using jQuery.noConflict().
var $j = jQuery.noConflict();
// Use jQuery via jQuery(...)
$j(document).ready(function(){
   $j("div").hide();
});

9. Is there any difference between body onload() and document.ready() function?

Ans: document.ready() function is different from body onload() function for 2 reasons.
We can have more than one document.ready() function in a page where we can have only one body onload function.
document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.

10. What is a CDN?

Ans: A content delivery network or content distribution network (CDN) is a large distributed system of servers deployed in multiple data centers across the Internet. The goal of a CDN is to serve content to end-users with high availability and high performance.
There are 3 popular jQuery CDNs.
1. Google.
2. Microsoft
3. jQuery.

11. What are selectors in jQuery and how many types of selectors are there?

Ans: To work with an element on the web page, first we need to find them. To find the html element in jQuery we use selectors. There are many types of selectors but basic selectors are:

Name: Selects all elements which match with the given element Name.
#ID: Selects a single element which matches with the given ID
.Class: Selects all elements which match with the given Class.
Universal (*): Selects all elements available in a DOM.
Multiple Elements E, F, G: Selects the combined results of all the specified selectors E, F or G.
Attribute Selector: Select elements based on its attribute value.

12. What are the fastest selectors in jQuery?

Ans: ID and element selectors are the fastest selectors in jQuery.

13. What are the slow selectors in jQuery?

Ans: class selectors are the slow compare to ID and element.

14. Which is fast document.getElementByID('txtName') or $('#txtName').?

Ans: Native JavaScipt is always fast. jQuery method to select txtName "$('#txtName')" will internally makes a call to document.getElementByID('txtName'). As jQuery is written on top of JavaScript and it internally uses JavaScript only So JavaScript is always fast.

15. Difference between $(this) and 'this' in jQuery?

Ans: this and $(this) refers to the same element. The only difference is the way they are used. 'this' is used in traditional sense, when 'this' is wrapped in $() then it becomes a jQuery object and you are able to use the power of jQuery.
$(document).ready(function(){
    $('#spnValue').mouseover(function(){
       alert($(this).text());
  });
});
In below example, this is an object but since it is not wrapped in $(), we can't use jQuery method and use the native JavaScript to get the value of span element.
$(document).ready(function(){
    $('#spnValue').mouseover(function(){
       alert(this.innerText);
  });
});

16. How do you check if an element exists or not in jQuery? 

Ans: Using jQuery length property, we can ensure whether element exists or not.
$(document).ready(function(){
    if ($('#element').length > 0){
       //Element exists
  }
});

17. How do you check if an element is empty?

Ans: There are 2 ways to check if element is empty or not. We can check using ":empty" selector.
$(document).ready(function(){
    if ($('#element').is(':empty')){
       //Element is empty
  }
});
And the second way is using the "$.trim()" method.
$(document).ready(function(){
    if($.trim($('#element').html())=='') {
       //Element is empty
  }
});

18. What is the difference between jquery.size() and jquery.length?

Ans: jQuery .size() method returns number of element in the object. But it is not preferred to use the size() method as jQuery provide .length property and which does the same thing. But the .length property is preferred because it does not have the overhead of a function call.

19. What is the difference between $('div') and $('<div/>') in jQuery?

Ans: $('<div/>') : This creates a new div element. However this is not added to DOM tree unless you don't append it to any DOM element.
$('div') : This selects all the div element present on the page.

20. What is the difference between parent() and parents() methods in jQuery?

Ans: The basic difference is the parent() function travels only one level in the DOM tree, where parents() function search through the whole DOM tree.

21. What is the difference between .empty(), .remove() and .detach() methods in jQuery?

Ans: All these methods .empty(), .remove() and .detach() are used for removing elements from DOM but they all are different.

.empty(): This method removes all the child element of the matched element where remove() method removes set of matched elements from DOM.

.remove(): Use .remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

.detach(): This method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time.

22. Explain .bind() vs .live() vs .delegate() vs .on()

Ans: All these 4 jQuery methods are used for attaching events to selectors or elements. But they all are different from each other.

.bind(): This is the easiest and quick method to bind events. But the issue with bind() is that it doesn't work for elements added dynamically that matches the same selector. bind() only attach events to the current elements not future element. Above that it also has performance issues when dealing with a large selection.

.live(): This method overcomes the disadvantage of bind(). It works for dynamically added elements or future elements. Because of its poor performance on large pages, this method is deprecated as of jQuery 1.7 and you should stop using it. Chaining is not properly supported using this method.

.delegate(): The .delegate() method behaves in a similar fashion to the .live() method, but instead of attaching the selector/event information to the document, you can choose where it is anchored and it also supports chaining.

.on(): Since live was deprecated with 1.7, so new method was introduced named ".on()". This method provides all the goodness of previous 3 methods and it brings uniformity for attaching event handlers.

23. What is event.PreventDefault?

Ans: The event.preventDefault() method stops the default action of an element from happening. For example, Prevents a link from following the URL.

24. What is the difference between event.PreventDefault and event.stopPropagation?

Ans: event.preventDefault(): Stops the default action of an element from happening.
event.stopPropagation(): Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. For example, if there is a link with a click method attached inside of a DIV or FORM that also has a click method attached, it will prevent the DIV or FORM click method from firing.

25. Can you include multiple version of jQuery? If yes, then how they are executed?

Ans: Yes. Multiple versions of jQuery can be included in same page.

26. In what situation you would use multiple version of jQuery and how would you include them?

Ans: Well, it is quite possible that the jQuery plugins which are used are dependent on older version but for your own jQuery code, you would like to use newer version. So because of this dependency, multiple version of jQuery may required sometimes on single page.
Below code shows how to include multiple version of jQuery.
<script type='text/javascript' src='js/jquery_1.9.1.min.js'></script>
<script type='text/javascript'>
 var $jq = jQuery.noConflict();
</script>
<script type='text/javascript' src='js/jquery_1.7.2.min.js'></script>
By this way, for your own jQuery code use "$jq", instead of "$" as "$jq" refers to jQuery 1.9.1, where "$" refers to 1.7.2.

27. What is chaining in jQuery?

Ans: Chaining is one of the most powerful feature of jQuery. In jQuery, Chaining means to connect multiple functions, events on selectors. It makes your code short and easy to manage and it gives better performance. The chain starts from left to right. So left most will be called first and so on.
The above jQuery code sample can be re-written using chaining. See below.
​$(document).ready(function(){
    $('#dvContent').addClass('dummy').css('color', 'red').fadeIn('slow');  
});​

28. How to write browser specific code using jQuery?

Ans: Using jQuery.browser property, we can write browser specific code. This property contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9.

29. Can we use jQuery to make ajax request?

Ans: Yes. jQuery can be used for making ajax request.

30. What are various methods to make ajax request in jQuery?

Ans: Using below jQuery methods, you can make ajax calls.
load() : Load a piece of html into a container DOM
$.getJSON(): Load JSON with GET method.
$.getScript(): Load a JavaScript file.
$.get(): Use to make a GET call and play extensively with the response.
$.post(): Use to make a POST call and don't want to load the response to some container DOM.
$.ajax(): Use this to do something on XHR failures, or to specify ajax options (e.g. cache: true) on the fly.

31. Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()?

Ans: By using jQuery post()/ jQuery get(), you always trust the response from the server and you believe it is going to be successful all the time. Well, it is certainly not a good idea to trust the response. As there can be n number of reason which may lead to failure of response.

Where jQuery.ajax() is jQuery's low-level AJAX implementation. $.get and $.post are higher-level abstractions that are often easier to understand and use, but don't offer as much functionality (such as error callbacks).

32. 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

33. What are deferred and promise object in jQuery?

Ans: Deferred and promise are part of jQuery since version 1.5 and they help in handling asynchronous functions like Ajax.






Thursday, 9 April 2015

CSS Interview Questions And Answers

1. What are different ways to apply styles to a Web page?

Ans: There are three ways to include css in our html page or web page.
Inline CSS
syntax: <div style="color:red;">some text here</div>
Internal CSS
Syntax: <style>
.selecter{
color:red // we can write any properties
}
</style>
External CSS
Syntax: <link rel="stylesheet" type="text/css" href="style.css">

2. If we have same css property for inline and interanl which one will apply?

Ans: inline css property is giving more priority. so inline css propery will applay
     priority order inline css -> internal css -> external css

3. What is an !important CSS?

Ans: if we write somthing like p{color:red}, p{color:blue !important};
      paragraph(p) will take the blue color.
      we are explicitly saying take the specipic property
      And also we can change the priority of Question 2

 6. What is Grouping?

Ans: When more than one selector shares the same declaration, they may be grouped together via a comma-separated list; this allows you to reduce the size of the CSS (every bit and byte is important) and makes it more readable. The following snippet applies the same background to the first three heading elements.

h1, h2, h3 {background: red;}

7. What are selectors in CSS?

Ans: Selectors help to select an element to which you want to apply a style.
    example: class, id, tags (p,h1, h6,<div> <span>) ;

8. What is block level element and inline element?

Ans: A block element is an element that takes up the full width available, and has a line break before and after it. <h1>, <p>, <li>, and <div> are all examples of block elements.
An inline element only takes up as much width as necessary, cannot accept width and height values, and does not force line breaks. <a> and <span> are examples of inline elements.

9.  Explain the difference between visibility:hidden and display:none.

Ans: visibility:hidden simply hides the element, while it will still take up space and affect the layout of the document.
display:none also hides the element, but will not take up space and the page will appear as if the element is not present.

10. What are some of the new features and properties in CSS3?

Ans: Box model
New Web fonts
Rounded corners
Border Images
Box Shadows, Text Shadows
New Color schemes (RGBA)
Transform property
New Pseudo-classes
Multi-column layout
New Gradients

11. What is an ID selector?

Ans: An ID selector is a name assigned to a specific style. In turn, it can be associated with one HTML element with the assigned ID. Within CSS, ID selectors are defined with the # character followed by the selector name.
#example1: {background: blue;}
<p id="selector">...</p>

12. What is a class?

Ans: A class is a style (i.e., a group of CSS attributes) that can be applied to one or more HTML elements. This means it can apply to instances of the same element or instances of different elements to which the same style can be attached. Classes are defined in CSS using a period followed by the class name. It is applied to an HTML element via the class attribute and the class name.
.classexample {font-family: Helvetica; font-size: 20; background: black;}
<div class="classexample">....</div>

13. What is the difference between an ID selector and CLASS?

Ans: An ID selector identifies and sets style to only one occurrence of an element, while CLASS can be attached to any number of elements.

14. What are child selectors?

Ans: A child selector is used when you want to match an element that is the child of another specific element. The parent and child selectors are separated by spaces. The following selector locates an unordered list element within a paragraph element and makes a text within that element bold.
p > ul {font-weight: bold;}
classname1 classname2 { color:red};
classname2 is child class.

15. What are pseudo classes?

Ans: Pseudo classes allow you to identify HTML elements on characteristics (as opposed to their name or attributes). The classes are specified using a colon to separate the element name and pseudo class. A good example is the :link and :visited pseudo classes for the HTML A element. Another good example is first-child, which finds an element's first child element.
The following CSS makes all visited links red and green, the actual link text becomes yellow when the mouse pointer is positioned over it, and the text of the first element of a paragraph is bold.
a:link {font-color: red;}
a:visited {font-color: green;}
a:hover {font-color: yellow;}
p.first-child {font-weight: bold;}
p:nth-child(number){
color:red;
}

15. What are pseudo classes?

Ans: Pseudo classes allow you to identify HTML elements on characteristics (as opposed to their name or attributes). The classes are specified using a colon to separate the element name and pseudo class. A good example is the :link and :visited pseudo classes for the HTML A element. Another good example is first-child, which finds an element's first child element.
The following CSS makes all visited links red and green, the actual link text becomes yellow when the mouse pointer is positioned over it, and the text of the first element of a paragraph is bold.
a:link {font-color: red;}
a:visited {font-color: green;}
a:hover {font-color: yellow;}
p.first-child {font-weight: bold;}
p:nth-child(number){
color:red;
}

16. What are Sass, LESS, and Stylus? Why do people use them? How does something like Compass relate to Sass?

 Ans: They are CSS preprocessors. They are an abstraction layer on top of CSS. They are a special syntax/language that compile down into CSS. They make managing CSS easier, with things like variables and mixins to handle vendor prefixes (among other things). They make doing best practices easier, like concatenating and compressing CSS.

 17. Describe what a “reset” CSS file does and how it’s useful. Are you familiar with normalize.css? Do you understand how they differ?

 Ans: Resets are so wildly common in CSS that anyone who is a front end developer type has surely used them. Do they do so blindly or do they know why? The reason is essentially that different browsers have different default styling for elements, and if you don't deal with that at all, you risk designers looking unnecessarily different in different browsers and possibly more dramatic breaking problems.

Normalize you might call a CSS reset alternative. Instead of wiping out all styles, it delivers a set of reasonable defaults. It doesn't unset things that are already consistent across browsers and reasonable (e.g. bold headers). In that way it does some less than a reset. It also does some more than a reset in that it handles quirks you may never consider, like HTML5 audio element inconsistencies or line-height inconsistencies when you use sub and sup elements.

18. What is responsive design all about?

Ans: It's about making websites work wherever the web is. Different devices with different sizes and different capabilities. Responsive design is about taking one code base and making it work for all of them. Part of that is media queries and different visuals. Part of that is different resources (e.g. different JavaScript to handle touch vs click or different images to accommodate the screen).

19. What are the various techniques for clearing floats?

Ans: Floats are still incredibly common. As this is published, still probably the most cross-browser consistent way to build layout and grids. Anyone who has worked with them is aware of float collapsing. That is, floated element do not add to the height of a parent element. So for example if a parent element contained only floated elements, it would collapse to zero height. You can deal with that like:


Use a clearfix (bonus points for micro clearfix).
Float the parent as well.
Use an overflow property other than "visible" on the parent (bonus points for listing downsides like cutting off shadows).
Bonus points for "create a new block formatting context". Possibly negative points for something like <br style="clear: both;">

20. What is Box model ?

Ans: CSS box model is made up of margins, borders, padding, and content.
Box model provides a structured way to space elements in relationship to each other.
Padding: inside the cell spacing.
padding has 4 properties
padding-right :10px,padding-bottom :10px,padding-left :10px, padding-top :10px,
sorform of padding:
padding: 10 10 20 10;

margin : want to move the box(div) from outside we need to use margin
margin also having 4 properties like padding
margin:10 10 4 4;

Border: - This defines the maximum area in which the element will be contained. We can make the border visible, invisible, define height and width etc.


21. What are sprites and why would use them? How do you go about creating them? What are possible alternatives to sprites?

Sprites are essentially multiple images combined into one. Performance is the reason that they are used.