Sunday, May 28, 2017

HTML part 2

Unordered HTML List

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles) by default:
<!DOCTYPE html>
<html>
<body>

<h2>An unordered HTML list</h2>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

</body>
</html>

output

An unordered HTML list

  • Coffee
  • Tea
  • Milk

Unordered HTML List - Choose List Item Marker
The CSS list-style-type property is used to define the style of the list item marker:
ValueDescription
discSets the list item marker to a bullet (default)
circleSets the list item marker to a circle
squareSets the list item marker to a square
noneThe list items will not be marked
<!DOCTYPE html>
<html>
<body>

<h2>Unordered List with Disc Bullets</h2>

<ul style="list-style-type:disc">// change all list-style-type 
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

</body>
</html>

Ordered HTML List

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.

<!DOCTYPE html>
<html>
<body>

<h2>An unordered HTML list</h2>

<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

Ordered HTML List - The Type Attribute

The type attribute of the <ol> tag, defines the type of the list item marker:
<!DOCTYPE html>
<html>
<body>

<h2>Ordered List with Letters</h2>

<ol type="A">// change value type
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

TypeDescription
type="1"The list items will be numbered with numbers (default)
type="A"The list items will be numbered with uppercase letters
type="a"The list items will be numbered with lowercase letters
type="I"The list items will be numbered with uppercase roman numbers
type="i"The list items will be numbered with lowercase roman numbers


 WRITE CODE AND DISPALY NAVBAR

<!DOCTYPE html>
<html>
<head>
<style>
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333333;
}

li {
    float: left;
}

li a {
    display: block;
    color: white;
    text-align: center;
    padding: 16px;
    text-decoration: none;
}

li a:hover {
    background-color: #111111;
}
</style>
</head>
<body>

<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li><a href="#about">About</a></li>
</ul>

</body>
</html>
  • Use the HTML <ul> element to define an unordered list
  • Use the CSS list-style-type property to define the list item marker
  • Use the HTML <ol> element to define an ordered list
  • Use the HTML type attribute to define the numbering type
  • Use the HTML <li> element to define a list item
  • Use the HTML <dl> element to define a description list
  • Use the HTML <dt> element to define the description term
  • Use the HTML <dd> element to describe the term in a description list
  • Lists can be nested inside lists
  • List items can contain other HTML elements
  • Use the CSS property float:left or display:inline to display a list horizontally

The <div> Element

The <div> element is often used as a container for other HTML elements.
The <div> element has no required attributes, but both style and class are common.
When used together with CSS, the <div> element can be used to style blocks of content:

<!DOCTYPE html>
<html>
<body>

<div style="background-color:black;color:white;padding:20px;">
  <h2>NIIT ALAMABGH</h2>
  <p>SHUBHAM</p>
  <p>ASHISH</p>
  <p>shameel</p>
  <p>tanya</p>
  <p>dev</p>
  <p>puneet</p>
  <p>sharukh</p>
  <p>rashi</p>
</div> 

</body>
</html>
<div>Defines a section in a document (block-level)
<span>Defines a section in a document (inline)

HTML 5 part 1

HTML is the standard markup language for creating Web pages.
  • HTML stands for Hyper Text Markup Language
  • HTML describes the structure of Web pages using markup
  • HTML elements are the building blocks of HTML pages
  • HTML elements are represented by tags
Tag are two type:-

Paired and unpaired

Paired Tags:

A tag is said to be a paired tag if the text is placed between a tag and its companion tag. In paired tags, the first tag is referred to as Opening Tag and the second tag is referred to as Closing Tag.

Example

<i>This text is in italics. </i>
Note: Here <i> is called opening tag. and </i> is called closing tag.

Unpaired Tags:

An unpaired tag does not have a companion tag. Unpaired tags are also known as Singular or Stand-Alone Tags.

Example

<br> , <hr>

DOCTYPE is the first thing which should be present in an HTML5 document.
HTML5 doctype is written as <!doctype html>
'DOCTYPE' keyword is not case sensitive. So, <!doctype html> or <!DOCTYPE html>, both will do.
HTML5 doctype does not reference to a DTD. This is because, html5 is a SGML based, unlike HTML4.01 or XHTML1.
As soon a browser finds <!doctype html> in the starting of an HTML document, it represents the document in standard mode. If you don't use a doctype in the starting of an HTML document, the browser goes to the quirky mode. In that case, you may find that certain content is not being displayed the way you marked them up. So, it is a good practice to start your HTML document with a doctype. 

HTML Elements

An HTML element usually consists of a start tag and end tag, with the content inserted in between:
<tagname>Content goes here...</tagname>

HTML Attributes

  • All HTML elements can have attributes
  • Attributes provide additional information about an element
  • Attributes are always specified in the start tag
  • Attributes usually come in name/value pairs like: name="value"

HTML Headings

Headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading.

Example

<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
The HTML <p> element defines a paragraph
In HTML, links are defined with the <a> tag:
<a href="url">link text</a>

HTML Link Colors

By default, a link will appear like this (in all browsers):
  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red
You can change the default colors, by using styles:

Example

<style>
a:link {
    color: green; 
    background-color: transparent; 
    text-decoration: none;
}

a:visited {
    color: pink;
    background-color: transparent;
    text-decoration: none;
}

a:hover {
    color: red;
    background-color: transparent;
    text-decoration: underline;
}

a:active {
    color: yellow;
    background-color: transparent;
    text-decoration: underline;
}
</style>

HTML Links - The target Attribute

The target attribute specifies where to open the linked document.
The target attribute can have one of the following values:
  • _blank - Opens the linked document in a new window or tab
  • _self - Opens the linked document in the same window/tab as it was clicked (this is default)
  • _parent - Opens the linked document in the parent frame
  • _top - Opens the linked document in the full body of the window
  • framename - Opens the linked document in a named frame

Img for

<img src="url" alt="some_text" style="width:width;height:height;">


video for


<video src="path" alt="some_text" controls autoplay  style="width:width;height:height;">

Audio

<audio src="path" alt="some_text"  controls autoplay  style="width:width;height:height;">


  • Use the HTML <img> element to define an image
  • Use the HTML src attribute to define the URL of the image
  • Use the HTML alt attribute to define an alternate text for an image, if it cannot be displayed
  • Use the HTML width and height attributes to define the size of the image
  • Use the CSS width and height properties to define the size of the image (alternatively)
  • Use the CSS float property to let the image float
  • Use the HTML <map> element to define an image-map
  • Use the HTML <area> element to define the clickable areas in the image-map
  • Use the HTML <img>'s element usemap attribute to point to an image-map
An HTML table is defined with the <table> tag.
Each table row is defined with the <tr> tag. A table header is defined with the <th> tag. By default, table headings are bold and centered. A table data/cell is defined with the <td> tag.

HTML Table - Cells that Span Many Columns

To make a cell span more than one column, use the colspan attribute:

HTML Table - Cells that Span Many Rows

To make a cell span more than one row, use the rowspan attribute:


HTML Table - Adding a Caption

To add a caption to a table, use the <caption> tag:




Friday, May 26, 2017

How to store image in folder using php

<?php
   if(isset($_FILES['image'])){
      $errors= array();
      $file_name = $_FILES['image']['name'];
      $file_size =$_FILES['image']['size'];
      $file_tmp =$_FILES['image']['tmp_name'];
      $file_type=$_FILES['image']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
     
      $expensions= array("jpeg","jpg","png");
     
      if(in_array($file_ext,$expensions)=== false){
         $errors[]="extension not allowed, please choose a JPEG or PNG file.";
      }
     
      if($file_size > 2097152){
         $errors[]='File size must be excately 2 MB';
      }
     
      if(empty($errors)==true){
         move_uploaded_file($file_tmp,"images/".$file_name);
         echo "Success";
      }else{
         print_r($errors);
      }
   }
?>
<html>
   <body>
     
      <form action="" method="POST" enctype="multipart/form-data">
         <input type="file" name="image" />
         <input type="submit"/>
      </form>
     
   </body>
</html>

Saturday, May 13, 2017

Exception

What is exception

Dictionary Meaning: Exception is an abnormal condition.

In java, exception is an event that disrupts the normal flow of the program. It is an object which is thrown at runtime.

All exception classes are subtypes of the java.lang.Exception class. The exception class is a subclass of the Throwable class. Other than the exception class there is another subclass called Error which is derived from the Throwable class.
The Exception class has two main subclasses: IOException class and RuntimeException Class.

The exception handling in java is one of the powerful mechanism to handle the runtime errors so that normal flow of the application can be maintained.

What is exception handling

Exception Handling is a mechanism to handle runtime errors such as ClassNotFound, IO, SQL, Remote etc.

Advantage of Exception Handling

The core advantage of exception handling is to maintain the normal flow of the application. Exception normally disrupts the normal flow of the application that is why we use exception handling.


Types of Exception

There are mainly two types of exceptions: checked and unchecked where error is considered as unchecked exception. The sun microsystem says there are three types of exceptions:

Checked Exception
Unchecked Exception
Error

 Exception Handling Keyword
try
catch
finally
throw
throws