HEMANT SONKER’S BLOG

February 6, 2008

Validating flash

Filed under: HTML — Hemant Sonker @ 6:21 am

The code which is generated by macromedia dreamweaver for flash doesn’t validate in w3c in xhtml DTD.

It throws  error that embed is not a valid tag.blah blah…… Its better to use object which is a valid xhtml tag

Also it doesnt work in Firefox ,opera and netscape.After searching a lot on google basically from www.alistapart.com i found a way to work on flash code which works on all browsers.

This is done by this following code.

<!–[if IE]><object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″
codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0″ width=”100″ height=”120″>
<param name=”movie”
value=’some.swf’>
<![endif]x–>
<!–[if !IE]> <–>
<object type=”application/x-shockwave-flash” data=”some.swf” width=”100″ height=”120″ >
<!–> <![endif]–>
<param name=”movie” value=”some.swf” />
<param name=”quality” value=”high” />
</object>

enjoy…….this code works on all browsers.

February 5, 2008

Validating Iframe

Filed under: HTML — Hemant Sonker @ 8:23 pm

As a developer ,i came across a solution for validating iframes in strict DTD. As iframe is a depreciated tag, still it works in html 4.01 ,xhtml1.0.But its better to use object in place of iframe.

<object> is for inserting any foreign object into XHTML documents. Since Iframes include HTML/XHTML documents, the MIME type for the document is “text/html” or “application/xhtml+xml”. We will use the first one because it is compatible with all browsers including Internet Explorer.

Let me show you by an example.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>
<head>
<title></title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
</head>
<body>
<object style=”width:500px; height:200px” data=”http://www.google.com” type=”text/html” standby=”Google”></object>
</body>
</html>

Let me briefly explain the terms which are used in the above snippet.

  • classid - Defines a ClassID in the registry.
  • data - The URL of the object (required).
  • name - The name of the object if you are using it in JavaScript/VBScript or some other scripting language.
  • standby - Text to display when loading.
  • type - The MIME type of the object . Required.

When you run this example it is xhtml validated wheteher its transitional or strict.

September 21, 2007

Grouping of elements (span and div)

Filed under: HTML — Hemant Sonker @ 12:16 pm

The elements <span> and <div> are used to group and structure a document and will often be used together with the attributes class and id.

We will take a closer look at the use of <span> and <div> as exactly these two HTML elements are of central importance with regards to CSS.

Grouping with <span>

The element <span> is what you could call a neutral element which does not add anything to the document itself. But with CSS, <span> can be used to add visual features to specific parts of text in your documents.

SPAN is an inline element, so it may be used just as elements such as EM and STRONG in HTML. The important distinction is that while EM and STRONG carry structural meaning, SPAN has no such meaning. It exists purely to apply style, and so has no effect when the style sheet is disabled.

For example

<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>grouping with span</title>
<style>
.abc{color:#ff0000;
font-size:16px;}
.xyz{color:#1E3593;
font-size:10px;}

</style>
</head>
<body>
<p>This tutorial helps beginners learn the basics of creating Web sites with<span class=”abc”> HTML</span> and <span class=”abc”>Cascading Style Sheets.</span></p>
<p>This is a test to define grouping of elements in <span class=”xyz”>span </span>and <span class=”xyz”>div</span></p>
</body>
</html>

save this code and run.you will see the effects.

Grouping of elements with div

The DIV element is similar to the SPAN element in function, with the main difference being that DIV (short for “division”) is a block-level element. DIV may contain paragraphs, headings, tables, and even other divisions. This makes DIV ideal for marking different classes of containers, such as a chapter, abstract, or note

Aside from this difference, the grouping with <div> works in more or less the same way. Let us take a look at an example

<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>grouping with span</title>
<style>
#democrats{color:#ff0000;
font-size:16px;}
#republicans{color:#1E3593;
font-size:10px;}

</style>

</head>

<body>

<div id=”democrats”>
<ul>
<li>Franklin D. Roosevelt</li>
<li>Harry S. Truman</li>
<li>John F. Kennedy</li>
<li>Lyndon B. Johnson</li>
<li>Jimmy Carter</li>
<li>Bill Clinton</li>
</ul>
</div>

<div id=”republicans”>
<ul>
<li>Dwight D. Eisenhower</li>
<li>Richard Nixon</li>
<li>Gerald Ford</li>
<li>Ronald Reagan</li>
<li>George Bush</li>
<li>George W. Bush</li>
</ul>
</div>

</body>

</html>

Hope u would have come to know about the use of div and span.

if any queries ,please comment on it.i will get back to you.

Deprecated Elements in HTML

Filed under: HTML — Hemant Sonker @ 11:17 am

According to the W3C standrds, they have identified the following as depreciated tags.These tags if used may differ in differnt browsers like firefox,safari,opera,aol,IE6 ,IE 7 etc.

Deprecated Tags
<applet> use <object> tag (caution, not well supported yet)
<basefont> use style sheets
<blockquote>  
<center> use style sheets
<dir> use <ul>
<em> use style sheets
<font> use style sheets
<isindex> use <input>
<listing> use <pre>
<menu> use <ul>
<plaintext> use <pre>
<s> use <del>
<strike> use <del>
<strong> use style sheets
<u> use style sheets
<xmp> use <pre>

addition to tags, several attributes (modifiers to tags which set specific behaviors) are depreciated. These are listed in the table below.

Deprecated Attributes
align
alink
background
bgcolor
color
hspace
link
size
text
type
vlink
vspace

Differneces between XHTML and HTML

Filed under: HTML — Hemant Sonker @ 11:08 am

HTML is rapidly being replaced by XHTML. The differences are very minor, but the results of switching can be worth the effort. The primary benefit is that XHTML is more widely accepted in non “computer” devices like cell phone, palm devices and other scaled down browsers. This is commonly called portability between devices.
XHTML is also said to be extensible, which is the fancy way of saying the new tags can be added without a new document type declaration.

Firstly, what are the differences:

  • the tags in the page MUST be in lower case, so instead of <IMG src=”resource/frankisboat.gif” WIDTH=”389″ HEIGHT=”227″ BORDER=”0″ ALT=”boat”>, as we would do in HTML, we instead use: <img src=”resource/frankisboat.gif” width=”389″ height=”227″ border=”0″ alt=”boat” />
  • all tags must close, either by using a corresponding closing tag which has a slash, like paragraph ( <p></p> ) for example, or some tags are self closing like the above img src tag and line break ( <br /> ). In HTML, many of these tags were simply left open.
  • all tags must be properly nested, so if you start tag “a” and then start tag “b”, you must close tag “b” before you close tag “a”
  • some tags which were previously allowed are no longer allowed, although see the discussion below of document type declarations (DTD’s).
  • all attributes must also be lowercase
  • all values for attributes must be encased in single or double quotes
  • all attributes must be long form, not abbreviated, for example: disabled=”true” in XHTML vs DISABLED in HTML
  • structure must be separated from content. So for example, the <p> tag is a content tag (paragraph) so you can’t put a table in it for example, because a table is a format construct. You can however put the <p> tag inside <td> </td> tags with no problem because the content goes in the construct, not the other way around.

    The first thing you will notice if you look at the source of an XHTML document is that the first line is a document type declaration (DTD also called the DOCTYPE). There are three that are used, strict (that will only validate if you have no deprecated tags), transitional (which will still validate with deprecated tags) and frameset (which is for a page that “sets” up “frames”). Oddly enough, even though all tags in XHTML are lower case, parts of the DTD must be in upper case. The three DTD’s look like this:

  • Strict -
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “DTD/xhtml1-strict.dtd”>
  • Transitional -
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
  • Frameset -
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “DTD/xhtml1-frameset.dtd”>

Depreciated tags in XHTML (they are also depreciated in HTML 4), and at least be aware of the tags that are “depreciated”, tags like: <center>, <u> and <font>. Also be aware that some tag attributes are depreciated, like ‘align’ for example.
These tags are depreciated because what they do (or did) can now be better or more easily done with CSS.

The Difference between strict and transitional HTML / XHTML:
In short, transitional is a forgiving form of doctype as it allows depreciated tags and attributes to pass validation, and the browser will do its best to display the page as you wanted it. You must still have properly nested lowercase tags to get validation though.

The strict doctype is just that, all the depreciated tags and attributes will fail to validate under a strict doctype and may well display incorrectly as well.

July 23, 2007

Chapter 3:HTML & CSS:-Positioning

Filed under: HTML — Hemant Sonker @ 9:15 pm

Page layout with css positioning

So how are positioning and style sheets related? The original cascading style sheets recommendation included very little related to page lay out. With CSS1

* the width and height of an element can be specified
* margins and padding can be specified on an element
* text indent can be applied to the first line of an element
* float and clear provide the means to create columnar layout (up to a point)

Definitely lacking from this list is the ability to specify where the top or left hand side of an element should be.

So what is missing from CSS when it comes to page layout?  Blocks can overlap one another, and the front most block obscures blocks underneath it. With HTML, even including CSS1, we can’t do these things.

CSS2 provides the ability to do these kinds of “page layout” things.
Layers

Before we continue, it’s best that we address an important source of misunderstanding, namely the idea of layers. Most developers will have heard of layers, and many will have developed some erroneous ideas about them. Let me try to clarify matters a little.

In one sense, there is no such thing as a layer. In another sense, a layer is a metaphor, but layers themselves don’t exist. . Let me try and explain all this mess.

When we use the term layer, we generally mean an HTML container (or element) that can be placed at some specific location on a web page. . The first confusion that arises about layers in this sense is that many believe a layer is a DIV and can only be a DIV .
A layer in the sense of an HTML element placed somewhere on a web page can be any kind of element (a paragraph, a list item, whatever). Well at least in theory. In practice, Netscape Navigator will let you position Paragraphs and other elements using CSS2, while Internet Explorer really does think that a layer is a DIV. But more of this later.

So, hopefully we’ve cleared up the first and second causes of uncertainty. There is no such thing as a layer HTML element, rather, layer is a term for any HTML element that is positioned on a web page using CSS2.

However, if you take Netscape’s word for it, there is such a thing as an HTML layer, namely the <layer> element. This was a Netscape extension to HTML, that has never been adopted by Internet Explorer, and is certainly not recommended HTML. Simply ignore it, and it should go away.

Having hopefully cleared up these possible stumbling blocks, lets get down to understanding how positioning works.

Positioning in detail

The CSS2 recommendation provides a model for how elements can be positioned. Essentially there are four different ways in which an element can be positioned on a page, with a couple of complicating factors.

Static Positioning

Static positioning is easy. It’s how pages are already laid out by a web browser. A web browser takes an HTML file, parses it into its elements, applies style from a style sheet (or if there is none, from a default style sheet) and then “flows” the elements onto the page. The position that an element, say a paragraph, has in this flow is its static position. We’ll need to remember static positioning when we get to relative positioning below.

Absolute Positioning

Absolute position is what we are all so excited about. In a nutshell, it lets a developer say where the top left hand corner of an element should be located. We’ll look at how we do this a little later, but for now, consider this complicating factor. Suppose I say, P#title {position: absolute; top: 200px; left: -100px;}

Is this with respect to the top left hand of the web page, or the element which contains the paragraph of ID title? With CSS2, its the latter. That is, with CSS2, when you specify a position, it is with respect to the position of the parent element. Don’t get this confused with relative positioning, which we’ll look at below.

Fixed Positioning

Fixed position is a subset of absolute position. When an element is absolutely positioned, its positioned with respect to the element which contains it. When the page is scrolled, the element also scrolls. Wouldn’t it be nice if we could position elements with respect to the top of the window, so that regardless of how the page is scrolled, the elements remain fixed? You guessed it, fixed positioning provides precisely this feature. With fixed positioning and the OBJECT element in HTML, we can do away with frames forever, yet gain all the advantages, with none of the disadvantages of the FRAME construct.

Relative Positioning

Relative positioning is probably a little unfortunately named. Positioning relative to what? A lot of people jump to the conclusion that relative positioning is when you specify a position with respect to the parent element, and absolute positioning is when the position is specified with respect to the top left hand corner of the page. But as we have just seen, this is not how it works.

OK, so what is relative? In essence, relative positioning places an element with respect to where it would statically be positioned. When you relatively position an element, as a developer you are saying to a browser: “hey, take this paragraph, and put it 10 pixels down and 10 pixels to the right of where it would normally be.”

As we saw with absolute positioning, there is another complicating factor. What if we have a relatively positioned parent element, with an absolutely positioned child element? By analogy with absolute positioning you’ll probably guess that the absolutely positioned child element will be placed with respect to the top left hand corner of the parent element.

The issue of positioning isn’t particularly difficult, I trust, but it is a bit tricky. I hope this irons out the issue of the different kinds of positioning available in CSS2. A little later we’ll look at how to put these into practice.

Types of Element

Before we continue with a detailed analysis of the different positioning properties, and how they can be used, let’s take a quick look at the different kinds of HTML elements, and how these interact with positioning.

CSS and HTML provide three kinds of HTML elements

  • block elements
  • inline elements
  • list item elements

Block elements are separated from surrounding elements in the flow of the HTML page. <P> and <DIV> are examples of block elements.

Inline elements are not separated from surrounding elements in the flow, but rather follow directly on from their adjacent elements. <B> and <CITE> are examples of inline elements.

List item elements display similarly to block elements, but in addition, a marker (a bullet, or an alpha numeric character) is added to the left of the element.

Now, the CSS2 recommendation does not discriminate between different elements or kinds of elements when it comes to positioning. Theoretically, you can position a <CITE> element absolutely, just as you can a <DIV> relatively, or a <P> statically. In practice, browsers don’t support positioning particularly extensively. To be safe, apply absolute position only to DIVs.

Positioning Properties

We looked at the big picture, and the theory, now we are going to take a look at the detail, and learn how to implement what we’ve been talking about. In this section we take a look at each of the CSS2 properties.

position
What it does

The position property specifies how an element should be positioned. Above we saw that there are four types of positioning, static, absolute, fixed and relative.

Default Values

If no position is specified for an element, it has a position of static.

Is it inherited?

position is not inherited, however, keep in mind that the position of a parent element can affect the position of its children.

‘left’
What it does

Specifies where the left hand side of an element should be positioned.

If an element has a static position, this property has no effect

If an element has a relative position, then this property specifies where the element should be placed with respect to where it would be statically placed. For example, H1 {position: relative; left: 10%} places the left hand side of Headings of level 1 10% of the width of the parent element to the right of where they would otherwise be.

If an element has an absolute position, this property specifies where the left hand side of the element should be with respect to the left hand side of the parent element.

If an element has a fixed position, it specifies the left hand side with respect to the left hand edge of the window.

Possible Values

left can be specified as

  • a percentage
  • a unit value
  • by the keyword auto

Percentage values refer to that percentage of the width of the parent element.

auto refers to the current location of an element.

Default Values

If no left is specified for an element, the default value is auto.

Is it inherited?

left is not inherited, but the left of an element may be affected by the position of its parent element.

‘top’
What it does

Specifies where the top side of an element should be positioned.

If an element has a static position, this property has no effect

If an element has a relative position, then this property specifies where the element should be placed with respect to where it would be statically placed.

If an element has an absolute position, this property specifies where the top side of the element should be with respect to the top side of the parent element.

If an element has a fixed position, it specifies the top side with respect to the top edge of the window.

Possible Values

top can be specified as

  • a percentage
  • a unit value
  • by the keyword auto

Percentage values refer to that percentage of the height of the parent element.

auto refers to the current location of an element.

Default Values

If no top is specified for an element, the default value is auto.

Is it inherited?

top is not inherited, but the top of an element may be affected by the position of its parent element.

‘width’
What it does

This property specifies the width of an element. It can be applied to block elements, replaced elements (elements like IMGs) and any element with a position of absolute or fixed.

Possible Values

width can be specified as

  • a percentage
  • a unit value
  • by the keyword auto

Percentage values refer to the width of the parent element.

Unit values (such as pixels and ems) allow the specification of width using values with these units.

A width of auto places the right edge of the element immediately inside the right inner edge of its parent element.

Default Values

If no value is specified for width, the default value is auto.

Is it inherited?

width is not inherited from the parent element.

‘height’
What it does

This property specifies the height of an element. It can be applied to block elements, replaced elements (elements like IMGs) and any element with a position of absolute or fixed.

Possible Values

height can be specified as

  • a percentage
  • a unit value

Percentage values refer to the height of the parent element.

Unit values (such as pixels and ems) allow the specification of height using values with these units.

Default Values

If no value is specified for height, the default value is auto.

Is it inherited?

height is not inherited from the parent element.

‘overflow’
What it does

Because height and width can be specified, we face the potential problem that the content of an element will not fit into its area. What’s to be done? If you are familiar with frames, you might be able to guess.

The overflow property allows you to specify what happens in this situation. Content that does not fit inside the area can be clipped, can overflow, or scroll bars can be drawn to accommodate the content, as happens with frames.

Possible Values

overflow can be specified as one of

visible

Specifies that the width and or height of an element should be adjusted to accommodate the contents that don’t fit into the original area of the element.

hidden

Specifies that the contents should be ‘clipped’ to the height and width of the element. Anything that does not fit into this area is not visible

scroll

Specifies that scroll bars should always appear on the element, regardless of whether they are necessary.

auto

Specifies that scroll bars should be drawn only when scrolling is necessary to accommodate the content that does not fit into the dimensions of the element.

Default Values

If no value is specified for overflow, the default is visible.

Is it inherited?

The overflow of an element is not inherited from its parent.

As with much of CSS2, the implementation of this property in the major browsers (Netscape 4 and 4.5 and Internet Explorer 4, 4.5 and 5) is poor.

z-index
What it does

Now that elements can be laid anywhere on a page, what happens when they overlap? Which of two or more elements obscures the others? The z-index property allows us to specify this.

Possible Values

z-index can be specified as either the keyword auto, or by using an integer.

A z-index of auto specifies that an element should be stacked on a page in the order it appears in the HTML source.

For example, with these paragraphs

<P>This is the first paragraph</P>

<P>This is the second paragraph</P>

The second paragraph is closer to the front of the page than the first paragraph. If for whatever reason these paragraphs overlapped, the second would obscure the first. This might happen with the following style sheet rule

P {position: absolute; left: 10px; right 10px}

Though I’m not sure why you’d have that rule.

Where z-index is specified using an integer, the higher the integer, the closer to the front of the page.

There are however some complicating factors. z-indexes are not applicable to the whole page, but only within a particular containment hierarchy. This means that the z-index of parent elements is important in determining which element obscures another. Let’s try an example.

Suppose you have an absolutely positioned image with a z-index of 10 in a paragraph of z-index 1, and an image of z-index 2 in another paragraph of z-index 5. If the two images overlap, which obscures the other? In this case it is the image with the lower z-index, because its parent paragraph has the higher z-index. So the paragraph with the higher z-index obscures the one with the lower z-index, and as a consequence the contents of the paragraph with the higher z-index obscure the contents of the paragraph with the lower z-index, regardless of the z-indexes of the contents.

It’s logical, if a little convoluted.

Another subtle aspect is the question of how to make the contents of an element be closer to the front of the page, or further from the front of the page than the element itself. When the z-index of an element is less than zero, then the parent element is closer to the front of the page, when the z-index of an element is more than zero, the element is closer to the front of the page.

Hope that’s clear.

Default Values

By default, the z-index is auto.

Is it inherited?

While z-index is not inherited, the above discussion explains how the z-index of a parent element is relevant to the element and its stacking order.

‘visibility’
What it does

visibility lets you specify whether or not an element is visible. You might wonder why anyone would want an invisible element, but keep in mind that web pages are dynamic, so that their state can change over time, or depending on user interaction. A lot of the current DHTML tricks do little more than manipulate the visibility of elements on a web page.

Possible Values

visibility can take one of three values

visible

as you’d guess, specifies that an element should be visible

hidden

as also should be apparent, specifies that an element should not be visible. Keep in mind that the element may not be visible, but its presence is still felt in how the page is laid out. The browser still allows space for the element (it is there after all) its just that the contents aren’t visible. If you want an element to be in the source but its presence to complete vanish, set the display to none (e.g. P {display: none}.)

inherit

If you want an element to have the same visibility as the element which contains it, then set the visibility to inherit.

Default Values

If no visibility is set, then an element has a visibility of inherit.

Is it inherited?

As we have seen, visibility can be inherited. By default it is.

clip
What it does

Clipping is a technical programming term that will probably gain some wider use just as the term rendering has over the last couple of years.

Think about a graphic that is larger than the web browser window that you are viewing it in. Does it spill outside the window? Not if the browser is well developed. The image is clipped to the window frame (technically to the frame of the viewport, which is the contents of the window).

With CSS2, you can specify the dimensions of an element that should be visible, and the element is clipped to this rectangle.

Possible Values

The clip is specified as a rectangle, with each edge of the rectangle (top, left, bottom, right) being specified as either a length value or by the keyword auto.

Alternatively, the clip can be specified as auto, which means essentially that the element shouldn’t be clipped.

Because this feature is as yet unsupported on any browser, we won’t go into any great detail.

Default Values

By default, the clip of an element is auto.

Is it inherited?

clip is not inherited. However, theoretically the clip of an element’s parent could cause the element to be clipped.

Hints and suggestions

Simply ignore this feature until told otherwise.

Hands on

Now that we know the theory behind positioning, let’s put it to practice with an exercise. Its quite straightforward, but has a nice effect, and should get you underway with positioning and style sheets.

Creating Drop Shadows

Drop shadows are a common effect, that on the web are impossible without resorting to graphics. Well, maybe not impossible,with CSS2.

Here is the problem. We want to create an effect where the text in a dark color is shadowed by the same text in a lighter color and offset a little to the right and down. Looks like we’ll need the use of the following properties

  • absolute position (to place the element and its shadow)
  • left to specify the position of the left edge of the element and its shadow
  • top to specify the position of the top edge of the element and its shadow
  • z-index to ensure that the shadow is beneath the text
Creating the element and its shadow

First we need to create the elements that will contain the text and its shadow. Note that we said in our discussion that CSS2 applies to any element. So in theory, you should be able to apply an absolute position to any element. In practice, web browsers support CSS2 in such a limited way, that only the DIV element is to be trusted for positioning.

Our first step is to create the HTML source for two elements, with identical text, which will become our element and its shadow.

We’ll need to create two DIVs, with the same content, but with different classes. Let’s call the classes text and shadow.

Creating the Style Sheet rules

Each element is going to be identical in a number of ways, and differ subtly in a number of others.

The content is going to be identical. The size and weight of the text is going to be identical. Both elements are going to be absolutely positioned.

The shadow is going to be a different color from the text. The top and left of the shadow will be a little offset from the top and left of the text.

We now need to create two rules. One to select a DIV of class text, the other to select a DIV of class shadow.

They will have the same font-size and font-weight properties. Make the text quite large and bold so as to be able to appreciate the effect.

You’ll then need to specify absolute positioning, and set the left and top of the text element, as well as a slightly offset left and top for the shadow element. Lastly, make the shadow a little different in color (usually a little lighter or darker) to complete the effect.

Make sure also that the text is on top of the shadow by setting the z-index of each appropriately.

Drop Shadows In Action

Have you previewed your handiwork? does it look like what you expected? You might need to tweak it by adjusting the top and left of the shadow. Also note that this isn’t a robust example. I wouldn’t trust it to work on every platform just because it works OK on yours.

I hope that it has been useful, and that I’ve cleared the air a bit about how positioning works, and how you can use it.

If you have any comments about the tutorial, and how it might be improved, please let me know.

Example Answers to Hands on Tutorial

Example HTML Source

<DIV class=”text”>This is an example of a drop shadow</DIV>

<DIV class=”shadow”>This is an example of a drop shadow</DIV>

Example Style Sheet

DIV.text {

font-size: xx-large;

font-weight: bold;

position: absolute;

left: 100px;

top: 100px;

z-index: 2

}

DIV.shadow {

font-size: xx-large;

font-weight: bold;

color: gray;

position: absolute;

left: 103px;

top: 103px;

z-index: 1

}

July 12, 2007

Chapter 2:HTML &CSS

Filed under: HTML — Hemant Sonker @ 7:05 am

If you are supposed to desgin a HTML,then you should have a vision that how your structure would look like.

Let us consider a example .I am desgining a structure having

a)Header

b)leftpanel

c)mainpanel where your content is.

d)footer.

I will not use any table structure format.It is a bad practice to use table layout structure according to the HTML standards.

The reason is :when the page loads on the web ,first the table is displayed and then the content.so it takes more time.thats why table structure format is rarely used.it is used in such cases where there is tabular data.

In this case we will use only divs.let us understand first what is div.basicallly you can say it as a block or a container kind of thing where your content is stored.

Another thing we will be using ID and Classes.

ID and classes solves the same purpose that is to identify something…suppose header ,mainpanel,footer..etc..But there is a basic difference between these two.

ID can be used only once with same name.For example if you are using ,<div id=”header”></div>..this can be used only once .but if you are using class ,it can be used nos of times solving our purpose.for example <div class=”inner”></div>.This can be used nos of times.

I have tried to differntiate between ID’s and Classes.I think it might be clear to you.

Where we were.We were supposed to look an example.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>
<head>
<title>Simple example</title>
<link rel=”stylesheet” href=”css.css” type=”text/css” />
</head>

<body>

<div id=”container”>

<div id=”header”>header</div>

<div id=”leftpanel” class=”floatLeft”>leftpanel</div>

<div id=”mainpanel” class=”floatLeft”>mainpanel</div>

<div id=”footer”>footer</div>

</div>

</body>

css :

/* CSS Document */
*{margin:0px;
padding:0px;}
.floatLeft{float:left;}
body{
background:#95A8C4;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
text-align:center;
color:#fff;
}
#container{
width:900px;
margin:auto;
text-align:left;}
#header{
background:#353E79;
height:50px;}

#leftpanel{
width:200px;
background:#757EC1;
height:800px;}

#mainpanel{

width:700px;
background:#D7DAEE;
height:800px;}

#footer{
clear:both;
height:50px;
background:#353E79;}

just try this example.save the css file in the same folder.

May 14, 2007

html and css basics

Filed under: HTML — Hemant Sonker @ 11:46 am

Chapter 1:Basics

HTML stands for hyper text markup language.It provides a means to describe the structure of text-based information in a document by denoting certain text as headings, paragraphs, lists etc and to supplement that text with interactive forms, embedded images, and other objects .

Let me show you an example what the html page contains.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>abc</title>

</head>

<body>

</body>

</html>

Let me clear what is written above.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” .there are four parts:

  1. DOCTYPE
    this tells the browser that this tag is a Document Type Declaration
  2. HTML
    the name of the DTD
  3. PUBLIC
    the DTD is available publicly
  4. -//W3C//DTD XHTML 1.0 Transitional//EN
    the actual DTD used for the document, in this case XHTML 1.0 Transitional in English.

There can be more than one DTD’s

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

The above url will give you the list of tags and their atributes which you can use in your html .If you want to see the list,just copy the url in the browser .

html xmlns=”http://www.w3.org/1999/xhtml” .This lines shows the start of html tag and the type of xml version which is used in the page.

Then there is starting of head tag in which your meta things are there .the crawler reads the meta things.then the head is closed.

Then there is title tag which is basically used for giving title to the page and offcourse there is closing of title tag and closing of head tag too.

The most important thing which comes is the body tag which contains your data which is displayed in the browser.The body tag is closed.

After the closing of body tag there is closing of html tag.

The page is to be saved by using html or htm extensions.One important thing i would like to tell that use all the tags in lowercase.

Blog at WordPress.com.