You are on page 1of 30

Html comment : example <!

-- This is a comment
-->

<html>
<head>
<style>
/*class selector example in css*/
.colorchange{ background-color:#FFFF33 }
.large{font-size:24px}
</style>
</head>

<body class="colorchange">
<p class="large">hello world
</body>
What is CSS?

CSS stands for Cascading Style Sheets

CSS defines how HTML elements are to be displayed

Styles were added to HTML 4.0 to solve a problem

CSS saves a lot of work

External Style Sheets are stored in CSS files

CSS Solved a Big Problem


HTML was NEVER intended to contain tags for formatting a document.
HTML was intended to define the content of a document, like:
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
When tags like <font>, and color attributes were added to the HTML 3.2 specification, it
started a nightmare for web developers. Development of large web sites, where fonts and
color information were added to every single page, became a long and expensive process.
To solve this problem, the World Wide Web Consortium (W3C) created CSS.
In HTML 4.0, all formatting could (and should!) be removed from the HTML document,
and stored in a separate CSS file.

CSS Syntax
A CSS rule set consists of a selector and a declaration block:

The selector points to the HTML element you want to style.


The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a property name and a value, separated by a colon.
<html>
<head>
<style>
body {
background-color: #d0e4fe;
}
h1 {
color: orange;
text-align: center;
}
p{

font-family: "Times New Roman";


font-size: 20px;
}
</style>
</head>
<body>
<h1>My First CSS Example</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output:

My First CSS Example

This is a paragraph.

Certified Ethical Hacking CEH v8 Training


Details:--------------------------------------------------------------- M1: Basic Networking Concepts (LAN, WAN & IP Addressing)

M2: OSI Model, TCP/IP Model, Networking Devices & Peer-Peer Networking
M3: Introduction to Ethical Hacking & its Phases
M4: IP Spoofing, MAC Spoofing, Anonmizer, TOR & Finding IP Addresses
M5: Information Gathering & Foot printing
M6: Advanced Google Techniques & Google Dorks
M7: Proxy Server & VPN
M8: Scanning Networks, Ping Sweeps, OS Finger Printing & Banner Grabbing
M9: System Security( Linux & Windows System Security)
M10: E-Mail Ethical Hacking, Secure Email, Email Tracking & Email Bombing
M11: Stopping Phishing attacks, Security of Facebook, Yahoo & Gmail Accounts
M12: Virus & worms
M13: Trojan, Backdoor, Spyware, Adware & Botnets
M14: Steganography (Hiding Images, text & data)
M15: Cryptograpghy & Keyloggers
M16: Sniffers, Exe Binders & Crypters
M17: Social Engineering
M18: DOS & DDOS attacks using Backtrack Linux 5
M19: Wireless Security (WEP, WPA & WPA2), Brute Force Attack & Its
preventation
M20: Firewall & Honeypots
M21: IDS & IPS
M22: SQL Injection & Shell Uploading
M23: XSS (Cross Site Scripting)
M24: Directory Traversal Attack, RFI & LFI
M25: Introduction to Android Ethical Security & Mobile Phone Ethical Security

M26: Introduction to Bluetooth Security


M27: Concept of Call Spoofing & SMS Spoofing
M28: Vulnerability Assessment & Penetration Testing
M29: Exploit Writing
M30: Cyber Crimes types & its prevention
M31: Basics of Python & Perl
M32: Security Projects & LinuxSoft Security Books (Free 5 Books)
LST CISEHE v8 L2 Online Exam & LAB Exam - Best Ethical hacking Training in
Jaipur

Address
Plot

No

:-

5,

Lalkothi

Apex

Scheme,

Indrapuri,

Near

SMS

Lane,

Stadium,

Behind

APEX-DIVYA

Tonk

MALL,
Road

Jaipur (Rajasthan) - 302015

Telephone

:-

+91-0141-4031790 , Mobile: 09828112636, 09314622544

Email
info@linuxsoft.co.intraining@linuxsoft.co.in

CSS Example
A CSS declaration always ends with a semicolon, and declaration groups are surrounded
by curly braces:
p {color:red;text-align:center;}

To make the CSS code more readable, you can put one declaration on each line.
In the following example all <p> elements will be center-aligned, with a red text color:

:-

<html>
<head>
<style>
p{
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Hello World!</p>
<p>This paragraph is styled with CSS.</p>
</body>
</html>
Output:

Hello World!
This paragraph is styled with CSS.

CSS Comments
Comments are used to explain your code, and may help you when you edit the source
code at a later date. Comments are ignored by browsers.

A CSS comment starts with /* and ends with */. Comments can also span multiple lines:

<html>
<head>
<style>
p{
color: red;
/* This is a single-line comment */
text-align: center;
}

/* This is
a multi-line
comment */
</style>
</head>
<body>

<p>Hello World!</p>
<p>This paragraph is styled with CSS.</p>
<p>CSS comments are not shown in the output.</p>

</body>
</html>
Output:

Hello World!
This paragraph is styled with CSS.
CSS comments are not shown in the output.

CSS Selectors
CSS Selectors
CSS selectors allow you to select and manipulate HTML elements.
CSS selectors are used to "find" (or select) HTML elements based on their id, class, type,
attribute, and more.

The element Selector


The element selector selects elements based on the element name.
You can select all <p> elements on a page like this: (all <p> elements will be centeraligned, with a red text color)

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

The id Selector
The id selector uses the id attribute of an HTML element to select a specific element.
An id should be unique within a page, so the id selector is used if you want to select a
single, unique element.
To select an element with a specific id, write a hash character, followed by the id of the
element.
The style rule below will be applied to the HTML element with id="para1":

Example
#para1 {
text-align: center;
color: red;
}
Do NOT start an ID name with a number!

The class Selector


The class selector selects elements with a specific class attribute.
To select elements with a specific class, write a period character, followed by the name of
the class:
In the example below, all HTML elements with class="center" will be center-aligned:

Example
.center {
text-align: center;
color: red;
}
You can also specify that only specific HTML elements should be affected by a class.
In the example below, all <p> elements with class="center" will be center-aligned:

Example
p.center {
text-align: center;
color: red;
}
Do NOT start a class name with a number!

Grouping Selectors
If you have elements with the same style definitions, like this:

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

you can group the selectors, to minimize the code.


To group selectors, separate each selector with a comma.
In the example below we have grouped the selectors from the code above:

Example
h1, h2, p {
text-align: center;
color: red;
}
<!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
}
</style>
</head>
<body>

Hello World!
This paragraph is not affected by the
style.

<p id="para1">Hello World!</p>


<p>This paragraph is not affected by
the style.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
p.center {

This heading will not be


affected
This paragraph will be red and center-

text-align: center;
color: red;

aligned.

}
</style>
</head>
<body>
<h1 class="center">This heading will
not be affected</h1>
<p class="center">This paragraph will
be red and center-aligned.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: red;
}
</style>
</head>
<body>

Hello World!
Smaller heading!

This is a paragraph.

<h1>Hello World!</h1>
<h2>Smaller heading!</h2>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">Red and centeraligned heading</h1>
<p class="center">Red and centeraligned paragraph.</p>
</body>
</html>

Red and center-aligned


heading
Red and center-aligned paragraph.

<!DOCTYPE html>
<html>
<head>
<style>
p{
text-align: center;
color: red;
}
</style>
</head>
<body>

Every paragraph will be affected by the


style.
Me too!
And me!

<p>Every paragraph will be affected by


the style.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>

CSS How To...


When a browser reads a style sheet, it will format the document according to the
information in the style sheet.

Three Ways to Insert CSS


There are three ways of inserting a style sheet:

External style sheet

Internal style sheet

Inline style

External Style Sheet


With an external style sheet, you can change the look of an entire website by changing
just one file!
Each page must include a reference to the external style sheet file inside the <link>
element. The <link> element goes inside the head section:

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

An external style sheet can be written in any text editor. The file should not contain any
html tags. The style sheet file must be saved with a .css extension. An example of a style
sheet file called "myStyle.css", is shown below:
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}

Do not add a space between the property value and the unit (such as
margin-left: 20 px;). The correct way is: margin-left: 20px;

Internal Style Sheet


An internal style sheet may be used if one single page has a unique style.
Internal styles are defined within the <style> element, inside the head section of an
HTML page:

Example
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>

<!DOCTYPE html>
<html>

This is a heading

<head>

This is a paragraph.

<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Inline Styles
An inline style may be used to apply a unique style for a single element.
An inline style loses many of the advantages of a style sheet (by mixing content with
presentation). Use this method sparingly!
To use inline styles, add the style attribute to 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 <h1> element:

Example
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>

<!DOCTYPE html>

This is a heading.

<html>

This is a paragraph.
<body>

<h1 style="color:blue;margin-left:30px;">This
is a heading.</h1>
<p>This is a paragraph.</p>

</body>
</html>

Multiple Style Sheets


If some properties have been defined for the same selector in different style sheets, the
value will be inherited from the more specific style sheet.
For example, assume that an external style sheet has the following properties for the
<h1> element:
h1 {
color: navy;
margin-left: 20px;
}

then, assume that an internal style sheet also has the following property for the <h1>
element:
h1 {
color: orange;
}

If the page with the internal style sheet also links to the external style sheet the
properties for the <h1> element will be:
color: orange;
margin-left: 20px;

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css"
href="mystyle.css">
<style>
h1 {
color: orange;
}
</style>
</head>
<body>

This is a heading
The style of this document is a
combination of an external stylesheet, and
internal style

<h1>This is a heading</h1>
<p>The style of this document is a
combination of an external stylesheet, and
internal style</p>
</body>
</html>

The left margin is inherited from the external style sheet and the color is replaced by the
internal style sheet.

Multiple Styles Will Cascade into One


Styles can be specified:

in an external CSS file

inside the <head> section of an HTML page

inside an HTML element

Cascading order
What style will be used when there is more than one style specified for an HTML element?

Generally speaking we can say that all the styles will "cascade" into a new "virtual" style
sheet by the following rules, where number three has the highest priority:
1. Browser default
2. External and internal style sheets (in the head section)
3. Inline style (inside an HTML element)

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css"
href="mystyle.css">
<style>
body {background-color: linen;}
</style>
</head>
<body style="background-color: lightcyan">
<h1>Multiple Styles Will Cascade into
One</h1>
<p>In this example, the background color is
set inline, in an internal stylesheet, and in an
external stylesheet.</p>
<p>Try experimenting by removing styles to
see how the cascading stylesheets work. (try
removing the inline first, then the internal, then
the external)</p>

Multiple Styles Will


Cascade into One
In this example, the background color is
set inline, in an internal stylesheet, and in
an external stylesheet.
Try experimenting by removing styles to
see how the cascading stylesheets work.
(try removing the inline first, then the
internal, then the external)

</body>
</html>

So, an inline style (inside an HTML element) has the highest priority, which means that it
will override a style defined inside the <head> tag, or in an external style sheet, or in a
browser (a default value).
Note: If the link to the external style sheet is placed below the internal
style sheet in HTML <head>, the external style sheet will override the
internal style sheet!

CSS Background

CSS background properties are used to define the background effects


of an element.
CSS properties used for background effects:

background-color

background-image

background-repeat

background-attachment

background-position

Background Color
The background-color property specifies the background color of an element.
The background color of a page is set like this:

Example
body {
background-color: #b0c4de;
}

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #b0c4de;
}
</style>
</head>
<body>
<h1>My CSS web page!</h1>
<p>Hello world! This is a
W3Schools.com example.</p>
</body>
</html>

My CSS web page!


Hello world! This is a W3Schools.com
example.

With CSS, a color is most often specified by:

a HEX value - like "#ff0000"

an RGB value - like "rgb(255,0,0)"

a color name - like "red"

Look at CSS Color Values for a complete list of possible color values.
In the example below, the <h1>, <p>, and <div> elements have different background
colors:

Example
h1 {
background-color: #6495ed;
}
p{
background-color: #e0ffff;
}
div {
background-color: #b0c4de;
}
<!DOCTYPE html>
<html>

CSS backgroundcolor example!

<head>
<style>
h1 {
background-color: #6495ed;
}

p{
background-color: #e0ffff;
}

This is a text inside a div element.


This paragraph has its own background
color.
We are still in the div element.

div {
background-color: #b0c4de;
}
</style>
</head>
<body>

<h1>CSS background-color example!


</h1>
<div>
This is a text inside a div element.
<p>This paragraph has its own
background color.</p>
We are still in the div element.
</div>

</body>
</html>

Background Image
The background-image property specifies an image to use as the background of an
element.
By default, the image is repeated so it covers the entire element.
The background image for a page can be set like this:

Example

body {
background-image: url("paper.gif");
}
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("paper.gif");
}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

Below is an example of a bad combination of text and background image. The text is
almost not readable:

Example
body {
background-image: url("bgdesert.jpg");
}

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("bgdesert.jpg");
}
</style>
</head>
<body>

<h1>Hello World!</h1>
<p>This text is not easy to read on this
background image.</p>

</body>
</html>

Background Image - Repeat Horizontally or


Vertically
By default, the background-image property repeats an image both horizontally and
vertically.
Some images should be repeated only horizontally or vertically, or they will look strange,
like this:

Example
body {
background-image: url("gradient_bg.png");
}
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image:
url("gradient_bg.png");
}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

If the image is repeated only horizontally (repeat-x), the background will look better:

Example
body {
background-image: url("gradient_bg.png");
background-repeat: repeat-x;
}
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image:
url("gradient_bg.png");
background-repeat: repeat-x;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

Note: To repeat an image vertically set background-repeat: repeat-y;

Background Image - Set position and no-repeat


Note: When using a background image, use an image that does not
disturb the text.

Showing the image only once is specified by the background-repeat property:

Example
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
}

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image:
url("img_tree.png");
background-repeat: no-repeat;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>W3Schools background image
example.</p>
<p>The background image is only
showing once, but it is disturbing the
reader!</p>
</body>
</html>

In the example above, the background image is shown in the same place as the text. We
want to change the position of the image, so that it does not disturb the text too much.
The position of the image is specified by the background-position property:

Example
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image:
url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
margin-right: 200px;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>W3Schools background norepeat, set position example.</p>
<p>Now the background image is
only shown once, and positioned
away from the text.</p>
<p>In this example we have also
added a margin on the right side, so
the background image will never
disturb the text.</p>
</body>
</html>

Background - Shorthand property


As you can see from the examples above, there are many properties to consider when
dealing with backgrounds.
To shorten the code, it is also possible to specify all the properties in one single property.
This is called a shorthand property.
The shorthand property for background is simply "background":

Example
body {
background: #ffffffurl("img_tree.png") no-repeat right top;
}

<!DOCTYPE html>
<html>
<head>
<style>
body {
background:
#ffffffurl("img_tree.png") no-repeat
right top;
margin-right: 200px;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>Now the background image is
only shown once, and it is also
positioned away from the text.</p>
<p>In this example we have also
added a margin on the right side, so
that the background image will not
disturb the text.</p>
</body>
</html>

When using the shorthand property the order of the property values is:

background-color

background-image

background-repeat

background-attachment

background-position

It does not matter if one of the property values is missing, as long as the ones that are
present are in this order.
This example uses more advanced CSS. Take a look: Advanced example