Monday, 6 March 2017

CSS Introduction


CSS Introduction

Take control of the style of your pages, including the colors and size of fonts, the width and colors of lines, and the amount of space between items on the page.
Allow you to specify rules that say how the content of elements within your document should appear.
CSS rule made up of two parts:
The selector , which indicates which element or elements the declaration applies to (if it applies to more than one element, you can have a comma - separated list of several elements)
The declaration , which sets out how the elements referred to in the selector should be styled
The declaration has two parts, separated by a colon:
A property , which is the property of the selected element(s) that you want to affect, in this case the width property.
A value , which is a specification for this property; in this case it is that the table cells should be 36 pixels wide.


HTML was NEVER intended to contain tags for formatting a document, it was intended to define the content of a document
The style definitions are normally saved in external .css files.
A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly braces:


CSS Selectors

CSS selectors are used to "find" (or select) HTML elements based on their id, class, type, attribute, and more.
Universal Selector
The universal selector is an asterisk; it is like a wildcard and matches all element types in the document e.g.
  *{  }
The element/Type Selector
Based on the element name e.g.
  p {
    text-align: center;
    color: red;
}
All <p> elements will be center-aligned, with a red text color
The id Selector
Uses the id attribute of an HTML element
The following applied to the HTML element with id="para1”
#para1 {
    
text-align: center;
    color: red;
}
 



The class Selector
Selects elements with a specific class attribute
All HTML elements with class="center" will be center-aligned

.center {
    text-align: center;
    color: red;
}


p.center {
    text-align: center;
    color: red;
}


Grouping Selectors
You can group the selectors, to minimize the code.
To group selectors, separate each selector with a comma.
h1 {
    text-align: center;
    color: red;
}

h2 {
    text-align: center;
    color: red;
}

p {
    text-align: center;
    color: red;
}


h1, h2, p {
    text-align: center;
    color: red;
}

CSS Selectors
The Child Selector
The child selector matches an element that is a direct child of another.
The names of the two elements are
separated by a greater - than symbol to indicate that b is a child of td ( > ) which is referred to as a
combinator :
  td > b {}
The Descendant Selector
The descendant selector matches an element type that is a descendant of another specified element (or nested inside another specified element), not just a direct child.
Example:
  table b {}
The Adjacent Sibling Selector
An adjacent sibling selector matches an element type that is the next sibling of another.
  h1+p {}
The General Sibling Selector
The general sibling selector matches an element type that is a sibling of another, although it does not have to be the directly preceding element
  h1~p {}




Thursday, 9 February 2017

Tables
Example
Basic Table Elements and Attributes
Grouping Sections of a Table
Splitting Up Tables Using a Head, Body, and Foot
Nested Tables
Accessible Tables


Tables
Display information in rows and columns
Used to display all manner of data that fits in a grid such as train schedules, television listings, financial reports, and sports results.
A row is made up of a set of cells on the same line from left to right
A column is made up of a line of cells going from top to bottom.
You create a table in XHTML using the < table > element.
Inside the < table > element, the table is written out row by row.
A row is contained inside a < tr > element — which stands for table row .
Each cell is then written inside the row element using a < td > element — which stands for table data .
Start each row and cell on a new line and to indent table cells inside table rows








Basic Table Elements and Attributes

< table >
The < table > element is the containing element for all tables. It can carry the following attributes:
All the universal attributes
Basic event attributes for scripting
dir
Indicate the direction of text
Possible values are ltr for left to right text and rtl for right to left
  dir=“ltr
Summary
Provide a summary of the table ’ s purpose and structure
  summary=”Table shows the operating profit for the last four quarters. The first column indicates the quarter, the second indicates outgoings, the third indicates receipts, and the fourth indicates profit.”



< tr >
Used to contain each row in a table
Carry five attributes, three of which have been deprecated in favor of using CSS.
  align bgcolor char charoff valign
char
Specify that the contents of each cell within the row will be aligned around the first instance of a particular character
  char=”.”
< td > and < th >
Elements Represent Table Cells
< th > element are usually displayed in a bold font
<td> displayed left - aligned and not in bold
< td > and < th > elements can also carry the following attributes:
abbr align axis bgcolor char charoff colspan headers height nowrap rowspan scope valign width
< caption >
Table should have a caption so that visitors to your site know what the table is for.
appears directly after the opening < table > tag
Associate the content of the table with its description




Splitting Up Tables Using a Head, Body, and Foot

< thead> to create a separate table header
<tbody> to indicate the main body of the table
<tfoot> to create a separate table footer
Note that the < tfoot> element must appear before the < tbody> element in the source document.


Accessible Tables

Ensure your tables are easy to understand with following:
Add captions to your tables
Always try to use the < th > element to indicate a table heading
Always put headings in the first row and the first column
Avoid using nested tables
Avoid using rowspan and colspan attributes
Learn how a voice browser or screen reader would read a table, and the order in which the cells are read out;
If you use the scope and headers attributes to clearly indicate which headings apply to which rows and columns, then screen readers can help users retrieve headings for a particular cell. 



Wednesday, 8 February 2017

HTML Concepts

HTML Documents
HTML documents contain HTML tags and plain text
HTML documents are also called web pages

Hyper Text 
A method by which you move around on the web - by clicking on special text called hyperlinks which bring you to the next page.
You can go to any place on the Internet whenever you want by clicking on links
There is no set order to do things in.

Markup 
It is what HTML tags do to the text inside them. They mark it as a certain type of text .

HTML Tags
HTML markup tags are usually called HTML tags
HTML tags are keywords (tag names) surrounded by angle brackets like <html>

HTML tags range from formatting commands to controls that allow user input

HTML tags normally come in pairs like <b> and </b>
The first tag in a pair is the start tag, the second tag is the end tag
The end tag is written like the start tag, with a forward slash before the tag name
Start and end tags are also called opening tags and closing tags
Example
  <tagname>  content </tagname>

HTML ELEMENTS
"HTML tags" and "HTML elements" are often used to describe the same thing.
But strictly speaking, an HTML element is everything between the start tag and the end tag, including the tags
Example:
  <p>This is a paragraph.</p>


HTML vs X HTML
HTML
HTML is an application of SGML (Standard Generalized Markup Language)
Allows an author to omit certain tags and use attribute minimization
X HTML
The Extensible Hyper Text Markup Language, or
X HTML, is an application of XML (Extensible Markup Language)
It doesn’t permit the omission of any tags or the use of attribute minimization
Basically, X HTML is HTML (all the html tags are found in X HTML) that follows the rules of XML (because it is a family of XML).
For example, while <br> is valid in HTML, it would be required to write <br /> in X HTML.

XHTML
All tags must be in lower case
All documents must have a doc type
All documents must be properly formed
All tags must be closed
All attributes must be added properly
Attributes cannot be shortened
All tags must be properly nested 
The <!DOCTYPE> Declaration

The <!DOCTYPE> declaration tells browser that this is an HTML page.
There are many different documents on the web, and a browser can only display an HTML page 100% correctly if it knows the HTML type and version used.
HTML5 Example:
<!DOCTYPE html>

Tuesday, 7 February 2017

Web Server
It is a computing server that enables HTTP access to a web site.
A web server runs many additional  services behind the scene, e.g., a database, a server application framework, authentication, etc.
Web server refer to either the hardware (the computer) or the software (the computer application) that helps to deliver web content that can be accessed through the Internet.
The term web server or
webserver can mean one of two things:
A computer program that accepts HTTP requests and return HTTP responses with optional data content.
A computer that runs a computer program as described above. 

Web Server Components
A web server typically include the following major components:
networking support : sending responses and receiving requests over the network;
address/domain resolution : analyzing the correct IP address for the requested (virtual) domain, authenticating if necessary;
request processing : serving static or dynamic content as appropriate;
response generation : building the response and passing it to the networking component.

Web Server Workflow
A web server has the following workflow steps:
1.receive a HTTP request;
2.translate the resource “path” based on the requesting URL;
3.check access based on the requested information;
4.validate the user id and authenticate the user if necessary;
5.determine the MIME (Multi-purpose Internet Mail Extensions) type of the requested resource;
6.generate the dynamic response if needed, i.e., running local scripts;
7.send response back
8.log the request.

URI(Uniform Resource Identifier )

It contains four distinct parts: the protocol 
type, the machine name, the directory path and the file name.
URI stands for Uniform Resource Identifier. URI is a text which is used to identify any resource or name in Internet.
URI has two specialization in form of URL (Uniform Resource Locator) and URN (Uniform Resource Name) to identify resource and name.





URI(Uniform Resource Identifier )

URL (Uniform Resource Locator)

Location dependent and is a subset of URI or Uniform Resource Identifier.
Includes location as well as protocol to retrieve the resource e.g. in http://abc.com/foldarname/filename.html, HTTP is a protocol which can be used to retrieve resource filename.htm available in location http://abc.com directory.
There are several kinds of URLs: file URLs, FTP URLs, and HTTP URLs.
It's not necessary that URL always include http as protocol, it can use any protocol e.g. ftp://, https://

URN (Uniform Resource Name)

URN is also subset of URI. One of the best example of URN is ISBN number which is used to uniquely identify a book.
URN is completely different than URL as it doesn't include any protocol