Showing posts with label Web Developer interview Questions answers. Show all posts

What's the difference between standards mode and quirks mode?

In the old days, pages were written in two versions:

  1. Netscape Navigator
  2. Microsoft Internet Exploreer
When W3C, was introduced, browsers could not just start using them as doing so would break most existing sites on the web. Browsers introduced two modes to treat new standards compliant sites differently from old legacy sites. 

Layout engines in browsers uses three modes:
  1. Quirks mode: In quirks mode, layout emulates nonstandard behavior in Navigator 4 and IE 5. These were needed for websites written before introduction of web standards. 
  2. Full standard mode: In this mode, the behavior described is same as described by HTML and CSS specifications. Most of the modern browsers uses full standard mode.  
  3. Almost standard Mode: In almost standard mode there is very small number of quirks implementation. 


Make sure you put the DOCTYPE right at the beginning of your HTML document. Anything before the DOCTYPE, like a comment or an XML declaration will trigger quirks mode in Internet Explorer 9 and older.
The DOCTYPE as, <!DOCTYPE html>, is the simplest possible, and the one recommended by HTML5. Earlier versions of the HTML standard recommended other variants, but all existing browsers today will use full standards mode for this DOCTYPE, even the dated Internet Explorer 6. 
Learn more »

How would you optimize a website's assets/resources?

  1. Image of Proper Size: Always using image of proper size and specifying height and width of image is good idea.
  2. Compressing image, Use Photo shop, Save for Web
  3. Use of Sprites
  4. Caching:
    $expire = 60 * 60 * 24 * 1;// seconds, minutes, hours, days
    header('Cache-Control: maxage='.$expire);
    header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expire).' GMT');
    header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
  5. Data URI Scheme / Inline Images
$picture = fread($fp,filesize($file));
fclose($fp);
// base64 encode the binary data, then break it
// into chunks according to RFC 2045 semantics
$base64 = base64_encode($picture);
$tag = '<img src="data:image/jpg;base64,'.$base64.'" alt="" />';
$css = 'url(data:image/jpg;base64,'.str_replace("\n", "", $base64).'); ';
 
Learn more »

What is the difference between tags and elements (HTML)?

Tags are just HTML tag that has just opening or closing entity. For example:
<p> and </p> are called HTML tags.

HTML element encompasses opening tag, closing tag, content (optional for content-less tags) Eg:
<p>This is the paragraph</p> : This complete thing is called a HTML element. 


<h3>This is the H3 heading level.</h3> Here, <h3></h3> are HTML tags and the entire statement, <h3>This is the H3 heading level.</h3> is referred as HTML element.

HTML attributes
An attribute defines a property for an element, consists of an attribute/value pair, and appears within the element’s start tag. An element’s start tag may contain any number of space separated attribute/value pairs.
The most popular misuse of the term “tag” is referring to alt attributes as “alt tags”. There is no such thing in HTML. Alt is an attribute, not a tag.
Learn more »