HTML & CSS: Basic Web Dev Lessons
HTML & CSS: Basic Web Dev Lessons
Content
Html Introduction
Exercise
Advantages of CSS
Selectors
Key Concepts
Example
Introduction [Contd]
Web Browser
Establishes the connection to the specified Web server, at the
requested URL (Uniform Resource Locator (URL)
Interprets and formats the information found on the server, and
displays the formatted information.
Web Server
A computer that delivers/serves Web pages.
Every Web server has an IP address and possibly a domain name.
E.g:I f you enter the URL http://www.yahoo.com/index.html in your
browser, this sends a request to the server whose domain name is
yahoo.com. The server then fetches the page named index.html
and sends it to your browser.
Each Web server contains documents that are written in the
Hypertext Markup Language (HTML)
Requests and responses are exchanged between Web browsers and
Webservers using the Hypertext Transfer Protocol (HTTP)
Introduction [Contd]
Introduction [Contd]
URL Basics
URL types:
Absolute URLs
Relative URLs
Fragment URLs
Absolute URLs
Absolute URLs use a complete Internet address to give the location of
a resource.
Examples:
http://msdn.microsoft.com/support/index.asp
http://msdn.microsoft.com/code/welcome.asp?frame=true
URL Basics
Relative URLs
Relative URLs are used for accessing files when the full Internet
address is unnecessary.
Examples:
index.asp
/index.asp
welcome.asp?frame=true
Fragment URLs
Fragment URLs are used to access to a specific location within a URL.
Examples:
http://www.someplace.com/shopping.html#books
Any HTML file should start with the tag <HTML> and end with the
tag </HTML>
The text between the start and end tags is the element content
HTML tags are not case sensitive, <b> means the same as <B>
Uses of Hyperlinks:
Structure of Hyperlinks:
Example
Code: <IMG SRC="starflower.gif" width="105" height="97" border="0">
Output:
Using tables you can control precisely how you want your
content divided up and where you want it placed.
Tables [Contd]
Eg.
<table border=1>
<tr>
<th>Year
<th>Amount
</tr>
<tr>
<td>2002
<td>85,000
</tr>
<tr>
<td>2001
<td>65,000
</tr>
</table>
Year
Amount
2002
85,000
2001
65,000
Heading
One
Two
</tr>
</table>
Specifying Rowspan
<table border=1>
<tr><td rowspan=2>One<td> Two
</tr>
<tr><td> Three</tr>
</table>
One
Two
Three
Frames [Contd]
frame.html
<frameset cols="20%,80%">
<frame name="toolbar" src="toolbar.html">
<frame name="content" src="index.html">
</frameset>
toolbar.html
<a href="index.html" target="content">home</a>
<a href="products.html" target="content">products</a>
<a href="info.html" target="content">about us</a>
<a href="feedback.html" target="content">feedback</a>
Frames [Contd]
Introduction
HTML Forms act as an Interface between the End User and the
server side Application. At client side the form is filled and data is
passed on to the server, where the data is interpreted and used
accordingly.
Different Elements
Form
Input
Textarea
Form Element
The form has got two main attributes viz.. Action and Method.
Input Elements
checkbox - Off/on
Hidden
Image
Password
Submit
Text
This can be used to enter text of a single-line in a text box
Eg. <input type=text name=firstname size=15
maxlength=20>
onChange is an event for Select box and directs the flow control to
the specified script function.
The default value if not specified explicitly for an option tag would
be its content.
Exercise
Create a simple HTML Registration Form web page having following field names,
Choose the appropriate form element for each field.
1 UserID
2 Password
3 RetypePassword
4 First Name
5 Last Name
6 Country List of some countries
7 City List of some states of that country
8 Your interests ---------Entertainment,Business, Shopping,Health,Music,Travel, Others Please
specify
9 Are you a fresher?
10 Write a note on your experiences at MindTree so far
11 Upload your Photo
12 Email ID
Provide all necessary buttons to suite this form. The submit button is an image.
CSS
Style sheets provide a means for authors to specify how they wish
documents written in a markup language such as XML or HTML to
be formatted.
CSS [Contd]
Why Style Sheets
HTML isn't designed for styling documents - when you write an HTML
document, you are specifying only the content that the element
contains. . If you wished to state that you want your headings to be
yellow Helvetica, then you could have <H1><FONT
color="yellow" face="Helvetica">A
heading</FONT></H1>, but this is bad for several reasons:
You have to add that piece of code to each heading that you want styled - this is
time-consuming, prone to error and makes files excessively bloated (a typical page
styled using HTML will be 1/3rd formatting tags).
If you want to change those headings to pink Arial, then you will have to change
each heading individually - a prohibitively laborious task on a large site.
CSS [Contd]
Style Sheets helps in cost reduction, but also the download speed
will increase for viewers of your pages
CSS [Contd]
Easy maintainance
They give far more control over formatting than HTML - such
features as background images and colors on all elements - not
just the whole document, etc.
CSS [Contd]
Inline Style
Inline Style
For example see the following snippet
<P style=color: green> Paragraph inline style </P>
Inside the style attribute comes style declarations. In this example, the P element is
being made green.
<BODY style=color: #FFFFFF; background:#000000> Paragraph
inline style </BODY>
In the above snippet we are applying the Inline style to the Body tag, which will give
the Black back ground to the body and White color for all the text which will appear
in the Body tag.
CSS [Contd]
<HTML>
<HEAD>
<STYLE type="text/css">
<!-BODY {color: red}
-->
</STYLE>
</HEAD>
<BODY>
The main Content will appear in the Body section
</BODY>
</HTML>
CSS [Contd]
They do not affect all the rest of the style sheets that you might use
CSS [Contd]
CSS [Contd]
See the following snippet for Linked Style Sheet
<HTML>
<HEAD>
<LINK rel="stylesheet" type="text/css" href="fluorescent.css">
</HEAD>
<BODY>
The Main content will appear here in the Body Section
</BODY>
<HTML>
Once you have linked the style sheet to your page, you then have
to create the style sheet. For example:
BODY {color: black;
font-family: Geneva, Helvetica, Arial, sans-serif;
background-color: white}
If you saved the example above as a style sheet, then every page
that links to it will have the specified styles.
CSS [Contd]
Disadvantage
CSS [Contd]
Importing Style Sheets
The @import rule thus allows you to keep some things the same while
having others different
It must come at the start of the style sheet, before any rulesets (a ruleset is
something like P {color: red})
However, Internet Explorer only supports the url() formats, not the " and '
formats.
CSS [Contd]
Selectors
To give you more freedom to select which elements your style is
applied to.
CSS [Contd]
Attribute Selectors:
Class
ID
The CLASS attribute enables you to apply declarations to a group of
elements that have the same value on the CLASS attribute
All elements inside BODY can have a CLASS attribute
CSS [Contd]
<HTML>
<TITLE>Class Attributes</TITLE>
<STYLE TYPE="text/css">
.boldtxt { font-weight: bold }
.nrmltxt { font-weight: normal }
</STYLE>
<BODY>
<P CLASS= boldtxt >This is Bold Text Line</P>
<P CLASS= nrmltxt >This is normal text line</P>
<P CLASS= boldtxt >Second Line of Bold Text</P>
<P CLASS= nrmltxt >Second Line of Normal Text</P>
</BODY>
</HTML>
CSS [Contd]
ID Attribute:
The ID attribute works like the CLASS attribute with one important
difference
The HTML syntax of the element on which you want to use the ID
attribute resembles that of other elements with attributes; for example:
<P ID=undltxt>Underlined text</P>
CSS [Contd]
Style Attribute:
<HTML>
<TITLE>Class Attributes</TITLE>
<BODY>
<P STYLE="font-weight: bold">This is Bold Text Line</P>
<P STYLE="font-weight: normal">This is normal text
line</P>
</BODY>
</HTML>
CSS [Contd]
/* unvisited link */
/* visited link */
/* active link */
CSS [Contd]
KEY Concepts
CSS [Contd]
CSS [Contd]
Here is the source file for the above program.
CSS [Contd]
CSS [Contd]
Here is the source file for the above program.
CSS [Contd]
CSS [Contd]
http://www.w3.org
http://www.htmlhelp.com
http://www.webreview.com
http://www.wdvl.com/Authoring/Style/Sheets/