Related Links |
Sticky PostingsIntroductionIntroduction:  Where do we start? Well if we follow the advice of our wise old ancestors we should ‘start at the beginning’. This book starts somewhere in the middle. Well, that may be a good place to start if you have some knowledge of what went before and have some understanding of the direction in which you want to head. Since you have picked up this book to read, we must assume that you do know what went before and what is to come after. Nevertheless, we must begin at the beginning if we want to identify and root out misconceptions about web design. Else we may find ourselves in difficulties. We may not understand or appreciate the problems of positioning elements and the throes of positioning them absolutely. So following the dictums of the ancestors we shall begin at the beginning. The web page is a derivative of the physical paper. However, it does not suffer from the limitations of a physical paper. Using paper is all about control. Its size is fixed. Its fonts cannot be fixed by the reader. It will remain same at the point of creation and at the point of distribution. The reader has no option but to accept what he gets! The web page is different. Its dimensions can be changed. The fonts can be changed; the look and feel can be changed. It is dynamic and pliable and fully capable of adapting itself to the visualization of the web designer. It can be customized to the needs of the user. It can be made accessible to the blind reader or cater to those who can see and hear. Software can be made to read the page for the visually impaired or adapt itself to Braille for those who read with the fingers. The presentation is only limited by the vision of the programmer and determined by the needs of the user.  Unfortunately, the web page seems to have broken all bounds and become uncontrollable. The designer cannot ensure that the web page remains the same at the point of creation and distribution! It takes on the shape of the window in which it is displayed and distorts the positioning of the elements that the designer so carefully laid out on the page! The chameleon like quality of the web page has exercised the minds of the web designer and the end user alike. It is a common plaintive theme that can be found in web design discussion forums and books that have been churned out on web design. The novice and the experienced, cry hoarse over the problem of control in web pages. “How do we control the look and feel of the web page in multitude of browsers and desktop resolutions?� “How do we ensure that the elements are positioned as designed in the final output that appears before the user?� The web designer must acknowledge the sad fact that he has no control over the display of his page. The reality he encounters is a far call from the ideal that he wants! He can at best attempt to direct the user experience. He will have to second guess the platform differences and resolution logic. He will have to try to render every page pixel perfect. Therefore, before we start on this book about absolute positioning it is important to understand that positioning of elements is a challenge and absolute positioning of elements is an absolute challenge. The designer is not God. He needs to rethink his role, to abandon control and seek a relationship with the page that has nothing to do with the “what we see is what we get (WYSIWYG)� world. He must accept that he needs to create adaptable pages in which content and appearance are two distinct elements. He must appreciate that it is the nature of the web to be flexible. So he must begin the journey by letting go of concepts of control of web pages and accepting that flexibility is the first mantra web design. If the dreams of a killer website have taken a beating, it is time to say that you have no cause to despair. Killer web pages have been created and continue to be created despite thes problems. However, concerted efforts are being made to discipline the web page. You may soon find that you have tools which enable you create web pages that look the same and display the same whatever the browser, the platform or the device! Microsoft, Netscape and Opera have rallied forces to deliver standard compliant browsers. While these standards do not provide you with complete control they at least help you create web pages that look fairly good on desktops and palmtops alike. The expectation is that you separate structure from presentation using semantic XHTML and CSS layout and do not get carried away with false convictions that backward compatibility with older browsers is a possibility. The web designer must understand that bygones will be bygones and they must let go of those browsers and push the new ones that are taming the world of web design for him. Now that the decks have been cleared of all misconceptions you are really ready to get started. So let me tell you what this book is all about. This book is about web designing as you have guessed. It is also about the problem of control. It is about positioning elements and advantages of absolutely positioning them. It is all about the challenge you are about to take up and the truths you are going to be forced to accept. So if you are ready, turn the page and begin your journey of discovery. Tuesday, January 9. 2007
Absolute Positioning? Absolutely Not! Posted by Steve Monas
in Chap 05 at
02:31
Comments (0) Trackbacks (0) Absolute Positioning? Absolutely Not!Absolute Positioning? Absolutely Not! Absolute Positioning? Absolutely not! This reaction to the process of absolutely positioning elements on a web page is understandable but not justified. Why ever not? Absolute positioning provides the designer with certain advantages and a quite a few disadvantages too. However, before we actually set out the long list of advantages and disadvantages, let us look at the concept of absolute positioning. Defining Concepts Absolute positioning defines the x and y coordinates of an element with reference to the top left corner of the browser page or the containing block and the position attribute is set to absolute. The code will read as under:
Note that the right and bottom coordinates have not been defined. So the text moves to the right and the bottom of the page. Specifying all four coordinates will give you greater control over the element. Absolute positioning removes the element from the normal flow of the document and it does not impact the other elements on the page when the page is loaded. This means that the element is placed in an arbitrary position somewhere in the viewport and its properties are set by the top, bottom, left and right attributes. A point that needs to be noted here is that if the absolutely positioned element is a child element of another element which has not been placed static, then the absolutely placed element will not be placed relative to the viewport, but relative to the parent box. In the following code three boxes have been specified. When the code is executed, box one will be placed relative to the view port. Box two will be placed absolutely and box three as the child of box two will be placed relative to box two.
The user agent or the application that processes the web page such as the browser selects the initial containing block. It also could be related to the veiwport. It is ok to assign negative values to the absolutely positioned elements. However, this may result in non-display of the element. Layers can be used to absolutely position elements on a page. Layers are created using the div tag as in the following code: <div style="position: absolute; left: 610px; top: 80px; height: 400px; width: 100px; padding: 1em;">layer stuff</div>
The advantage of using layers with div tags is that they load faster. All the style information is contained in the attributes added. The overlapping layers can be created using the z-index command. The values assigned to the z index will determine its order in the stack. The higher the index the closer the div will appear to the front of the page. The layer that holds the page’s content should be given the z index of one so that users can read the content and click on the navigation elements. Absolute positioning gives complete control over the elements of a web page to you. Once the element is pulled out of the flow it can be placed anywhere in the page and this will allow you the freedom to display your content before your navigation structures become visible. This enables you to provide the user with optimum accessibility and to optimize your content for search engines. However, absolute positioning can cause problems of overlapping if adequate care is not exercised. Layouts that use absolute positioning for columns can have problems with footer display if the column length is not correctly estimated. Comparing Concepts Most users are confused between absolute and relative positioning concepts in CSS. This is because of the coordinate system within which the block is placed. The block then depends on the positioning context and there is no universal set of coordinates to guide the designer. Whenever a new block is placed on the page it creates a positioning contexts for its descendents with reference to the upper left hand corner of the page. It another element is placed within the first element, its position will be calculated with reference to the top left corner of the containing block and not the page. The code fragment below will place an absolutely positioned element with reference to the top left corner of the page. <div class="MyTitle"  style="position:absolute; left:125px; top:75px;">  This text is being absolutely positioned with reference to the page. </div>
<div class="MyTitle" Â style="position:absolute; left:125px; top:75px;"> Â This text is being absolutely positioned with reference to the page. Â <div class="MyTitle" Â Â Â style="position:absolute; left:25px; top:30px;"> Â Â Â This is another absolutely positioned element within the first one. Â </div> </div>
If a third element is added using the relative positioning, it will be contained within the second element. Relative positioning will render the text slightly to the right of the second element within the span. This is because it calculates the position with reference to the original position on the page.
Combining Concepts Absolute positioning is relative!  In reality an absolutely positioned element is relative to the containing block. The containing block is the nearest positioned ancestor or the document’s initial containing block. It is a structurally superior element whose property is absolute or fixed or relative. The following example shows how an absolutely positioned element can be relative to the containing block. The H3 positioned as relative allows the span to be positioned relative to the containing header.
h3 span { <h3>Some header <span>!!!</span></h3>
A relative element can be nested in an absolute element. The relative element will be treated as a child of the absolute element and its position on the page will be determined in the context of the parent’s position on the page. The relative element is moved to its original position in the flow within the parent element. The code for this will read as under: .relpos { position: relative;
CSS allows overlay of elements to create a 3D effect. The elements can be absolutely positioned in such a way that they are positioned in overlapping layers. A stacking happens and the z index order value is used to position the layer in the stack and consequently the image or text. The code below is illustrative of this technique. It positions one image slightly above the other. .csslogo{ color: red;              font-size: 42pt;              font-weight: bold;              top:110px;              left: 80px;              position: absolute;              z-index:1             } .wkshop { color: black;              font-size: 26pt;              font-weight: bold;              top:140px;              left:200px;              position: absolute;              z-index:2             }
Saturday, January 6. 2007Layers and Positioning of ElementsLayers and Positioning of Elements A layer is a type of container. It can hold text, images, tables and other layers. While layers are extremely difficult to hardcode and a number of browsers do not support layers, they can be used to an advantage for obtaining text and image effects and for the creation of web sites that are creative. The web designer can also have immense versatility in the positioning of elements on a page. A number of software, like Dreamweaver have provided designers with tools for creation of layers with ease. Using Layers to Position Elements. Coordinates and positioning are two important attributes of the layer that have to be considered the moment the web designer works on his composition.  The coordinate system x/y begins with the top right corner of the page. Layers can be stacked or overlapped in the order supplied by the third coordinate called the z-index, which is used by the web browser to determine the topmost layer of the stack. Positioning of elements on a layer is similar to positioning of elements on the web page—static, relative and absolute. Static positions, as we have already stated, treat the image or text like a block in the normal flow. Relative positioning places the element with reference to the top left corner of the document. Absolute positioning takes the layer and the elements on it away from the normal flow and places them in coordinates of their own. They are not affected by the contents of the page. Attributes and Positions An HTML attribute or a style property is called a parameter in web design parlance. For instance, the ID parameter means either an ID attribute that can used with the <LAYER> tag or the ID Style property. However, property means Style property. The <LAYER> tag takes on pixels as the unit of measurement for attributes that specify the distance. Style properties are generally numerical values. The Position property only applies to layers that have been defined as styles and its value can be absolute or relative. ID is an identity for the layer and must begin with an alphabet. The ID can be used to refer to the layer in the code. This is an optional attribute. The Left and Top parameters are used to specify the horizontal and vertical positions of the top-left corner of the containing layer or page. The value has to be an integer. PageX and PageY properties are sometimes used to specify the horizontal and vertical positions in pixels of the top left corner of the layer relative to the enclosing document if there is no equivalent style property specified with the <layer> tag. The SRC and Source –include style attribute are used to specify the HTML document that needs to be displayed in a specific layer. This source file can include JavaScript code and all layers in the source file will be treated as child layers. This technique is useful if the content has to be dynamically changed constantly. The chef doesn't have to rewrite the entire page just to update the information about the special of the day. The Width parameter is used when the layer’s contents have to warp to fit within the layer. An integer value is normally used but percentages can also be ascribed. However if the layer contain images which cannot be warped the layer will ignore the width property and expand automatically to accommodate the width of the image. By default it will warp at the right boundary of the containing layer. The height parameter defines the initial height of the clipping region of the layer. This is expressed as an integer value or a percentage of the height of the containing layer. Like the width property, the height will also expand to accommodate elements which cannot be warped. By default the height is the minimum height for all the contents of the layer. The Clip property defines the clipping rectangle—that is the visible boundaries of the layer. It takes the top, left, right and bottom values as pixels. The left and right values are pixels with reference to the left edge of the rectangle and the top and bottom are defined with reference to the top edge of the layer itself. If the right and bottom values are specified the other two values will default to zero. If no value is specified, the values of the width and height will be determined by the contents of the layer. Z-Index, above and below are three attributes used by the <LAYER> tag for defining the stacking order of the layers. Values specified in these attributes will override default values. The topmost layer will have the highest z-index value. The Above attribute refers to the layer above the referenced layer and the below attribute refers to the layer immediately below the referenced layer. All nested layers are stacked above the parent layer. The visibility attribute will determine the visibility or invisibility of the layer. Pop up menus are examples of setting visibility attributes to layers. All submenus are created as invisible layers and they pop up on mouse-over events. HIDE hides the layer and INHERIT causes the layer to have the same visibility as the parent layer. This is also the default value. A layer with a visibility set to show may not be visible if there are other layers with the visibility set to show above it. By default layers are transparent. The BG-Color and Background-color can be specified to define the color of the layer.  The Background color will be applied to the rectangular region occupied by the layer. If a border is defined in the Style the region will be enclosed with a border in the color specified for the border.  The Background and Background-image style properties assign a tiled image across the background of the layer. The value specified is the URL of the image.  OnMouseOver and OnMouseOut, OnFocus, OnLoad, event handlers are functions or inline JavaScript code that can be invoked to make visible or invisible layers. Finally the NoLayer tag displays the content as if was not positioned at all. If layers functionality is required, it will generate JavaScript errors. Layers can contain applets and plugins which are special windowed elements that float on top of all layers—even when the containing layer is not visible. If these elements are moved to the edge of the containing layer they will disappear completely or partially(as in the case of form elements). Examples of Layer Positions Relative Positioning and Layers:Relatively positioned layers form part of the normal flow of the web page. These are also known as Inflow layers. These layers occupy space in the document flow and share line space with other elements of the web page.  The left and top attributes or properties can be set to specify the offset of the layer’s top-left corner from the current position of the document. The <ILAYER></ILAYER> tag is used while specifying an inflow layer. <ILAYER ID=layer2> In the following code relative position has been used to determine the positioning of layers: Sample ON TOP: <div style="position:relative; font-size:50px; z-index:2;">Sample</div> <div style="position:relative; top:-50; left:5; color:red; font-size:80px; z-index:1">Sampleagain</div> <div style="position:relative; top:-50; left:5; color:red; font-size:80px; z-index:4">Sampleagain</div> </body> </html> The web page will look as under: Absolute Positioning and Layers: Absolutely positioned layers can be defined with reference to its coordinates within its containing layer. The top, left corner of the layer can be set using the left and top attributes or properties. However, if these attributes are not set they will default to the top and left of the containing layer automatically. The absolutely positioned layer will not occupy space in the normal flow and will have no impact on the other elements on the page within the normal flow. The other elements on the page too will not make space for the absolutely positioned element in the normal flow. An absolutely positioned layer is created using the <LAYER> </LAYER> tag. If the layer has been defined as a style the layer will have to be created as under:
If the position is defined as Absolute in the example given for relative positioning, the web page will appear as under:
Note that the top layer has been defined using the z-index attribute in both instances cited above. Negative and positive values are acceptable while positioning layers. The positions can also be changed dynamically using JavaScript. This opens up immense possibilities. Whole games can be designed using layers with coordinates and positions defined. Or layers of pages can be created in a stack and clicking on a link can move the specified layer to the top.  Layer problems The most irritating problem about absolutely positioned layers is overlapping text. The moment a user resizes his text, all the beautiful layering done by the web designer takes a toss! The text begins to overlap. While Gecko browsers will allow the text to overflow, IE will expand the layers and overlap the borders of the layers too! The second layer will not move down to accommodate the first one as both are absolutely positioned and are not affected by the changes in the position of other elements! Another common problem with layers is that they will not stay put where the designer intended them to stay! If the layer is designed to be 800 pixel wide and the user has a screen that is 1024 pixel wide the layer will appear to jump a little to the left. While the actual layer has not moved a single pixel, it appears to move because it is absolutely positioned! In reality it is the table that has moved to the right to remain perfectly centered on the page. Since we do not have control over the user’s resolutions, it may be a good idea not to use absolute positioning? Maybe static positioning would server your ends better? Or maybe you could try setting margin and padding properties to resolve the issue?  In a sense setting the Margin and padding would solve the problem. Well ….Almost. The <div> containing the first layer will expand to accommodate the text if the font size is changed and the second layer will move to accommodate the changes in the first layer—rendering the layers correctly. The padding will take care of the space around the border and ensure that the text does not stick to the borders. A wrapper <div> can be used to enable the text to retain its positions relative to each other and the wrapper can be centered while the text remains at a specified position from the left of the browser viewport. Once all the above has been taken care of the designer will still have to deal with Browser bugs. Width is part of the content area. Any margin and padding added is included in the width in the determination of the area occupied by the element. Old Browsers do not recognize the box model which describes the width. Internet Explorer will calculate the width property and subtract the padding and borders before rendering the page. Well, you can imagine what will happen to all the positioning you have done when IE renders the page! To accommodate this bug in IE it has been suggested that web designers should ensure that the browser renders the page in Standards mode rather than in the quirks mode by including a Doctype in the page. The designer will also have to take care of the problems of IE 5x. A number of CSS hacks exist that can filter styles. These can be used or you could use a specific type of code that is called conditional comment. A code like the one under will be offered to IE 5x.   <!--[if IE 5]>
Stacking layersWe briefly discussed z-index order and stacking of layers. In this section we shall understand this concept better. CSS allows the designer position boxes on layers in addition to rendering the layers from 0 to whatever integer value he wishes to stack layers in the z-index property. The position of the layer in the Z axis is based on this integer value and higher the value the closer to the top the layer would be positioned. Default stacking rules Let us visualize a situation where no z index is assigned to a layer. What would be the stacking order--Default? The default order of stacking takes into account the background and borders of the root element, the descendant blocks in the normal flow –in the order of appearance in HTML, the descendent order of elements—again in the order of appearance in HTML. How floating elements can be handled The stacking of floating blocks is handled differently. They are placed between the non-positioned and the positioned boxes after taking into account the background and borders of the root element, the descendent blocks in the normal flow—in the order of their appearance in HTML, floating blocks and descendant positioned elements in the order of their appearance in HTML. Using z-index to change default stacking If a z-index is specified then the default stacking order is overridden and the specified stacking order takes effect. The z-index defines the position of the element in the z-index or third dimension of the page. The integer value can be positive or negative. The layer with the lowest index value will be the bottommost layer of the stack. If there are several layers with the same z-index value they are placed on the same layer. The stacking context In certain circumstances child stacking contexts can be created. For instance if a particular layer has a number of sub layers, the latter would be child layers for the said layer. A stacking context will have to be created for the child layers that are to be stacked on the parent layer. If an element is placed within another element and is given an z index value other than auto, then it creates its own stacking context. All child elements will then be stacked entirely within that context. The entire div and its contents are treated as single element in that layer.
Examples of stacking The code for the display of overlapping cells is given below for ease of understanding. Each <div> is defined, its properties set and then a z-index order has been assigned. Readers should try to reassign the z-index order or change the properties of the different divs to see the effect on the positioning of layers.
 <?xml version="1.0" encoding="utf-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">    <title>Understanding Stacking order</title>    <style type="text/css">     html {  </head>    <div id="div2">    <p> </p>    <div id="div3" style="position: absolute; left: 416px; top: 28px; width: 536px; height: 516px">      <div id="div4">      <h1>Division Element #3</h1>      <div id="div5">    </div>  </body>
Layers or tables? –this is a question that most designers ask themselves when they sit down to design their websites. If the target audience is still hanging on to the ancient browsers—the answer is simple—it has to be tables. However, if they have moved on to newer browsers—well, you could use layers. There is yet a third possibility. You could write codes for identifying browsers types and create a design that will convert your layers into tables and vice versa depending on the version of the browser! Software like Dreamweaver and Front page make the creation of layers or tables a breeze. The WYSIWYG editors help you move your layers and columns around without touching the code. In fact, a large number of designers subscribe to the view that it is easy to create layers and then convert them into tables. When layers are converted into a table, every layer is assigned a specific cell. Additional cells required to preserve the space between the layers are also created. Software that converts layers into tables also provides for aligning the layers edges if they are positioned within the specified number of pixels. This ensures that the resulting table will have less number of empty rows and columns. Often the last row of the table is filled with transparent GIFs to ensure that the table is displayed uniformly in all browsers. This type of table can be edited by dragging the columns. The Center option can be used to center the table on the page. The process of converting tables to layers is the reverse. Every cell in the table becomes a layer and additional empty cells used for maintaining the space between cells become space between the layers and so on. Saturday, January 6. 2007Using Layout ManagersUsing Layout Managers The Concept Layout managers were created to simplify interface design and free the designer from the drudgery of calculating the coordinates for each element on the page and worrying about properties, attributes and display problems relating to any specific elements. While the concept is laudable and helpful, it was not the ultimate panacea for the web designer’s problems. While it was possible to use different layout managers for different containers on a page and these layout managers gave sizes and positions to the components in the window and are helpful for windows whose size changed or were displayed on multiple operating systems, they did not provide the ultimate sought after solution. Complex layouts with nested containers, invisible components all come packaged with their own peculiar problems and layout managers can be as frustrating to the designer as manual arrangement of elements on a web page! A basic requirement of web design is portability. Standard UI design techniques do not guarantee portability. What looks beautiful on the design platform may be distorted beyond recognition in other platforms. The first portable layout managers were designed in Java with a guarantee of being deployable on multiple platforms.  These layout managers specified rules and constraints for the layout of the user interface. The advantages of these layout managers were that they correctly positioned components that were independent of fonts, screen resolutions and platform differences. They provided intelligent component placement for containers when they are dynamically resized. They also provided for ease of translation to make allowances for increase in the length of the string on translation. The Java UI container comes inbuilt with a special object called the layout manager. This component controls the components in the container. It automatically arranges the components in accordance with the rules, properties, constraints specified by the layout manager. The preferredSize, minimumSize, maximumSize, alignmentX and alignmentY and the size of the container are specified. The user can accept the default layout manager or override the settings and specify a custom layout manager. All layout managers use absolute positioning. Therefore, components do not adjust automatically when parent containers are resized. The properties of different layout containers are as under: BorderLayout has a hgap(horizontal gap) and vgap(vertical gap) to determine the distances between the components. Each component has a constraint value with possible values like North, south, east, west and center. FlowLayout and GridLayout properties can be used to align components with reference to the vertical and horizontal gaps. GridLayout also has the option of specifying the number of rows and columns. GridBagLayout has no properties. However, it has GridBagLayoutConstraints object associated with it which has properties of height and width of the component linked to it. It also has information about where the component in anchored in its cell, how the component fills up the cell, or how much padding surrounds the component inside its cell. Java uses different types of information to determine the position and size of components placed in the container. Layout managers in C# were different from the Java layout managers. While Java relegated layout managers to Graphical User Interfaces, in C# anything that implements Ilayoutable interface can be laid out. Moreover, since the layoutable objects are abstract concepts, distinct areas of the parent component can be laid out. This gives a lot of power to the web designer. Layout managers in Visual Studio 2003 are analogous to the layout managers of Java in that it implements Flow layout and Grid Layout. ASP.NET 2.0 introduced Master pages as a layout concept. Master pages implement standard visual and functional capabilities throughout the web based application and work in conjunction with content pages. Content will be populated into the placeholders for content provided in the master pages. Personalization features, takes the concept a little further by allowing users to select and populate their pages with components. Layout Examples TLB pages TLB stands for Translation look-aside buffer. This is a table in the processor’s memory and contains information about the recently created pages in the memory. The program’s virtual memory is cross-referenced with the corresponding absolute address in the physical memory. This enables faster computing. The TLB contains about 64-256 entries. The number of entries in the TLB is multiplied by the page size defined in the TLB reach. This is critical to the performance of the application and the performance begins to degrade once the TLB reaches the critical point. During the recent years the TLB is failing to keep pace with the increasingly large working sets of applications. Modern processor cache is getting large and few microprocessors have a TLB reach larger than the secondary cache for conventional page sizes. TLB misses become more common while accessing data from the cache and this increases the latency to memory. Efforts are being made to increase the TLB using the memory controller TLB. This will let the designer aggressively create super pages from non-contiguous, unaligned regions of the physical memory. Shadow pages are supported by the MTLB and this greatly empowers the Operating System’s ability to swap shadow-backed super pages more efficiently. Header and Footer Pages Sites that are several pages long would like to introduce a header and footer that will look identical on all pages. This header or footer should be capable of being changed when the designer wants to change the look and feel of the site. Header and footer pages are generally HTML pages that are part of the “includes� in PHP or master files in ASP.NET. Look at the following file created in PHP. <html> All pages associated with this header file will have to have the extension .php and then the header and footer files will have to be created. Enter all the details from the Layout that you want reflected in every page and name the file header.inc. The header file will appear as under: <html> Note that the code is truncated before the content starts. The Footer.inc file will reflect the footer layout as under: </div> Both the header.inc and the footer.inc files will have to be uploaded to the same folder as the pages in the website. Layout coding should not be part of any of the files in your folder, else your header and footer files will be overridden. At the head of every file enter the following code: <?php include("header.inc"); ?> Below the content, the following code will have to be added. <?php include("footer.inc"); ?> The include files can be named with any extension so long as the correct extension is specified in the include code.  In Java too, the include files can specify the header and footer files to be included as in PHP.  The classic ASP can include any type of script files as include files for headers and footers. The extension ASP or INC or HTM can be specified. The development of User controls offered greater flexibility, reliability and speed. Header user controls can be created by renaming the HTML file into head.ascx. The header must be registered and then called as under: <%@ Page Language="VB" runat="server" %> <body> ASP.NET 2.0 Master pages are used for creating consistent and maintainable interfaces and derives from the UserControl class. The PreInit event of the master page is called before the PreInit event of the content page is called and the content page fills into the content placeholder on the master page and becomes a child of the master page before it is displayed. In absolute positioning layout of components the footer pages will have to take into consideration the length of the longest column, while the header will have to take into consideration the start of the columns.. Floating Window Pages Floating windows help the designer divide the web page into rectangles that can be formatted independently of each other. They could be like DHTML layers—they can be hidden, shown or animated on top of the page. They can contain other HTML elements, such as text or image and another floating box if required. However, some web browsers do have problems with the floating windows, which have embedded floating boxes as the child-floating box inherits the CSS from the parent-floating box. A large number of designers are tending to move towards use of floating layers instead of popup windows. These are just HTML elements such as divs styled to sit on top of the rest of the page. This window usually has a close button on the top right corner for ease of dismissal. The important facts about floating windows are that popup blockers cannot block them. It forces the audience to look at the window—at least to figure out how it can be dismissed. If a link on the page is clicked the floating window will disappear with the rest of the page. Often JavaScript is used to close them but not for displaying them. They behave like normal windows on all computers. They cannot be minimized or resized. It is also not possible to switch back and forth between a floating window and the main page. Absolutely positioned floating windows have been used for creating attractive and “never scroll out of view� menus. Stretchable pagesWeb pages that stretch to fit into any window is the latest craze in web design. If the page does not stretch a lot of white space around it looks pretty bad. A simple solution is to center the design, but the white space remains a fact. Relative sizing using percentage values on tables does not allow for any arbitrary screen size. So stretching the pages to fit the window without distorting the elements composing it is a task that tests the ingenuity of the web designer. However, stretchable pages have some disadvantages. Stretching limits the page design and can cause readability problems. They should be used with caution and that too only with pages that have a great deal of content such as portal pages or company home pages. Stretchable pages must flexibly expand horizontally. This will be possible if solid color backgrounds are used or patterns that do not distort on stretching are used. Text is usually laid out in columns and more the columns the greater the ease of reading. However, if there are too few columns on a page, the text may stretch beyond a reasonable limit. Multiple column pages are easier to stretch for this reason. What has absolute positioning got to do with all the facts stated above? Absolute Positioning enables the designer design without layout managers! If the layout manager is set to null, the controls can be manually positioned using absolute positioning. However, it is not very comfortable to manually set the elements in their respective positions when the whole can be done with ease using a layout manager! Moreover, all components will get locked in place and will not adjust to the position and size if the window is resized. It is possible to take care of this issue also, but would require a lot of programming effort from your side. Saturday, January 6. 2007Concept of TemplatesConcept of Templates Much of the tasks in web page design are repetitive. The need to maintain a consistent look and feel throughout the site, the familiarity of users to the positioning of buttons and navigational elements and so on, makes it inevitable that some of the aspects of the design are repeated again and again. This results in a lot of time being expended on doing the same tasks over and over again. A template separates form from content and helps web designers layout elements on a generic page that can be called to provide the consistent look and feel of the website. Today, template designs provide a way of enforcing layouts, defining sets of privileges, style and content for multiple pages. The template can be divided into regions and tabs and styles can be applied to specific regions and items such as portlets can be added. At the other end of the spectrum, the user too, benefits from templating. The web designer now has the option to define themes or skins for web pages which can be accessed by users who wish to give a special feel to his page while retaining the underlying template that defines the look and feel of the website. These themes and skins are nothing but elements of a web page that have been pre-positioned for immediacy of deployment. With ASP.NET 2.0 the web designer can provide a repository of components to the web user for dragging and dropping into the web page. The end user has the freedom to position the elements on the web page! Evolution of the Concept of Templates The web designer needs to feel that he is in control of the way in which his web page displays the elements he has so carefully positioned. The end user wants to feel that he should have the ability to personalize the page to suit his tastes. There is a constant conflict of interest and the concept of templates has evolved from this fundamental need of both the designer and the user. Paper templates for entering structured information have always been around. The first web pages were designed as if were extensions of the paper format. Task based forms on the Internet, even today; share many of the features of the paper format. The word document is a template of the paper and Microsoft Word provides a large number of templates for jobs such as letter writing or resume writing. It enables users keep structure and content independent from each other and makes designer experimentation with templates wholly possible. The initial web pages were static pages and the initial efforts were directed towards experimenting with variations of the static page. The Cascading Style Sheets were the first efforts to distinguish between form and content. The possibility of creating “Styles� to which web content could be linked suggested undreamed of possibilities. A number of designers began to experiment with form. In fact it became such an obsession that flashy, buttons, colors and designs began to dominate the web. Form seemed to take precedence over content and communication. The moderate members of the profession vociferously expressed their discomfort with the state of things and a balance has gradually been achieved. Server side coding for templates emerged in the 1990’s. The Common Gateway Interface was first typically used in Unix Web servers for AWK report generator or M4 templates. The Server side ‘include’ helped in defining a more direct way of creating server side scripts on web servers.  Web portals, then, catalyzed the whole and web designers began to experiment with “template languages� and talk about the need for a “template standard language�. A template system now consists of a template engine that processes web templates and content information to produce web documents. The template engine can also be used as part of a preprocessor, filter or template processor. Programming languages such as PERL, Ruby, C or Java all support template processing natively or using add-on libraries and modules.  Java Server pages, Active Server pages, PHP are template engines in their own right. XSLT and Xquery designed by W3C have emerged with promises of future convergence of template languages! Templates can be simple “substitute templates� or masks where place variables are substituted with the web designer’s content or can be complex templates using XSLT schemas.  Masks or substitute templates are the first server side includes that created uniform headers and footers on the web page. Complex templates provide for standardized layouts using a single base layout over which other layouts are superimposed. A template can be defined as a piece of code that uses preset variables to expose data on a web page. The template can be further categorized into data templates and theme templates. Data templates are base templates on which theme templates are superimposed to give a customized look and feel to the web page.  Templating? A template is a kind of wire frame for the web page. The elements that must appear in every page on the website can be laid out in the frame to form a basic layout for the whole. The “All page template� is a general layout background for the website with a fixed header and footer with an “all content� variable. The block template is a segment or component region of the page with a specified layout block. The menu block that usually appears on the left hand side column of the page is an example of a template layout box in a dynamic web site. Strongly template oriented websites have databases that receive only pure content while the form is determined by the template and are not impacted by the content that is displayed on the page. Weakly template oriented websites allow the template design to be affected by the content and the template rules are changed every time the content changes. While the former can make for rigidity of design the latter can make for non standardized web pages. Providing for themes and skins probably emerged from a desire to mitigate the rigidity of strongly oriented web templates and to overcome the weakness of the weakly oriented ones. The template file is a single file that may reference other resources for logical dependencies or layout dependencies. The file is formatted with specific markup and reflects the template system strategies of the website. It uses scripts to provide instructions to the template engine and can be an embedded template language or an event driven template language. Embedded template language embeds the template script into a host language(old processor languages), while in an event driven template language (such as XSLT and filter languages) the template script treats each block as a separate event definition. A template language formalizes the variables, blocks, substitution rules or logic in a web template and the standards that can be fixed into engine dependent or independent contexts in accordance with the type of language selected. Simple substitution templates have only syntax rules and no logic and iteration. Iteration templates are similar to simple substitution templates but have inbuilt iterations that can repeat a substitution in the scope of a single block or several blocks. Programmable templates call functions that execute and impact the state or value of other variables. Complex templates have unrestricted logic and specify sequential algorithms and permit parameterization. Templates also fit in with the concept of object oriented programming. It encapsulates the concept and functionality so that it can be modified minimally without impacting the other parts of the application. If there are a large number of templates in a web site, template management demands the use of the Layout manager. The layout manager enables the management of layout in addition to the management of content in a web site. We shall be dealing with layout managers in greater detail in a later chapter. So we shall not say much more than this here. This chapter however, would be incomplete if we do not mention personalization, even though the details would be beyond the scope of this book.. Personalization of a site is the process of creating templates that filter and target the information displayed on the web site on the basis of the user’s identity and predefined needs. The pages are tailored to the user needs and are a common form of enhancing customer service or e-commerce sales and marketing. Personalization software includes software like Broadvision, ResponseLogic and Autonomy. ASP.Net personalization features take the whole technology one notch higher by allowing the user customized even the components that will be placed on the web page.  It introduces an generic storage system object called “profile’ which makes it easy to track and apply user preferences on web pages. Web design is maturing. It is becoming modular, object oriented and more scientific. It is concerned about usability issues and is focusing on creating websites that are user friendly and cross browser compatible. Positioning elements on a template and then deploying them across the website is a challenge by itself. Absolute positioning of elements in a template based web site is an absolute challenge. We shall be exploring this in a later chapter. Saturday, January 6. 2007
Pages, Page Sizes and Positioning of ... Posted by Steve Monas
in Chap 08 at
01:47
Comments (0) Trackbacks (0) Pages, Page Sizes and Positioning of ElementsPages, Page Sizes and Positioning of Elements Ultimately, what the user sees is a page. The layout of the page will impact on how the user rates the website. Flashy buttons, animations that distract and positioning of key elements including content, will all make the difference between the success and the failure of the page. This chapter intends to introduce you to the broad concepts that govern page layouts and how it impacts the overall impression that the web page creates on the user. Proximity of elements is the distance between the locations of elements on the web page. Proximity determines how elements relate to one another whether they are text, navigation or graphics. Elements that are placed close together appear to have a stronger relationship than elements that are farther apart. Generally speaking, elements that are close together appear to have a stronger relationship than elements that farther apart. For instance a caption for a picture must be placed directly below the picture and not a few inches below if it must establish a relationship. A subtitle must be directly below the title if it must make sense. A layout that positions elements in an unrelated manner is likely to be termed as weak. Therefore, positioning of elements on the web page will impact of the page on the user. Alignmentis one of the most critical principles of site layout that must be taken into consideration while designing the pages and positioning the elements of the page. It not only disturbs the readability of the page, but can also detract from the appearance. On most pages the alignment is from left to right. It provides a good starting point for the eye movement and the eye of the user is accustomed to this style unless he belongs to a culture that reads from right to left customarily.            Repetition is the art of saying the same thing over and over again without boring the reader with the intention of getting a point across. While web pages do not have to be the same across pages, users welcome repetition of some of the elements with slight variations for consistency. . For instance, placement of the logo on the upper left corner, the menu bar at the top of the page and so on adds to the look and feel of the site and provides a strong sense of familiarity to the user.   Contrast is used to make things stand out significantly. For instance the white of text against a dark background or the use of dark colored text on a white background. It makes reading easy and helps highlight it. Contrast can also be used to attract the attention of the user to a particular object on the page—such as a freebie or a competition announcement by making the text larger than the surrounding text or printing it in a significant color or positioning it in the middle of the page.           Navigation is another element that is carefully positioned on pages to hold the attention of the reader. It is a very important element on the page as it helps the reader get around the site with ease. Research has revealed that positioning of navigation elements is one of the main reasons that determine how long a visitor stays on the site. A number of navigation styles have consequently developed. The most common one is to position the navigation buttons at the top of the page so that they are visible to the user as soon as he enters the site.  Sometimes Navigation is provided for on the left of the page and sometimes on the right. A few sites prefer to have the navigation buttons at the bottom of the page. Some place it horizontally and some vertically. The type of site and the style of the site will determine the kind of navigation style that is used.   While top and left navigations are common and familiar to users, bottom navigation is advantageous when the pages are long and the user has to scroll through the page back to the top if the navigation is placed at the top. Sometimes the navigation links are duplicated at the top and the bottom of the page for ease of operation.  Text is the primary means of communication on a web page and hence has to be positioned in a central place on the page. Text is also displayed on different browsers in different ways because it relies on fonts installed on the user’s computer. So positioning of text and use of fonts that display well across browsers becomes an important aspect of page layouts. Almost all PC users have Arial and Times New Roman installed and Macintosh users have Helvetica and Times New Roman. So it would be safe to stick to these fonts while positioning text on the page. It must also be remembered that users read as a group of words. The size of the text then becomes the key element that determines how easy or difficult the text is to read. Large text is difficult to read if they have to read two words at a time and small text is difficult to read if groups of words are too closely packed. Consequently, it may be advisable to define the font size so that browser settings do not override the text and distort the page. High contrast between the text and background also makes the text easier to read. Red and blue texts create perception problems and should be avoided.            Page Size and Layout is extremely important factors in positioning of elements on a web page. This is one of the biggest challenges faced by web designers. Variability of screen sizes is incumbent upon the settings adopted by the user. Most computer monitors are set for 800 X 600 pixels. However, some monitors go in for lower or higher pixel settings. This can play havoc with the page and the positioning of elements on the page. Therefore, the web designer must create a web page that caters to all the different monitor settings and yet display well!  As pointed out earlier, knowing your audience is crucial to the kind of web page you design and how you place your elements on the page. If the audience is using older computers, then the screen resolution should be set for 640 pixel wide screen. If the audience is fairly tech savvy, you are likely to have an audience who has the screen set to 800 pixels and if you have a specialty audience then they are likely to be using an extremely wide monitor of 1024 pixels.   However, if your audience is extremely varied, then it would be best to design your screen for 640 pixels, center the page and allow the browser to display your web page smaller than the screen width. In this way you will not be sacrificing the positioning of elements at the altar of the screen width. However, there will a lot of “dead space� around the page, which cannot be used by the designer. Tables have been around for a long time as a method of laying out the pages. These are used to control the width of material presented on the web page. The table width is specified as a percent or pixels. Percent will cause the table size to change depending on what the viewer’s screen width is. The display is fairly uniform across browsers and screen sizes. It follows that the screen will be narrow in one monitor and wide in another if pixels are used to define the tables.  Use of frames in more elaborate websites throws up its own problems of positioning elements. It is also a moot point that a number of browsers do not support frames. Frames work by splitting up the browser window into two or three regions and displaying a separate page in each region. The problem of page layout is commensurate with the number of pages and frames on the screen at any given point of time. Each is an independent page and the positioning of elements in one page has nothing to do with the positioning of elements in another frame. One method of getting around the problem of frames and yet taking advantage of its capabilities is the use of a single large frame on a web page. It helps control with precision the placement of images and other items on the page. While a large number of browsers don’t support frames, they are more widely supported than layers or stylesheets and they open up the site to a wider potential audience. By adding the <NOFRAMES> tag and simply making a few minor adjustments to the framed area alone, anyone would have access to the information without having to build different versions of the same site. The concepts of frames has been taken a little further by the use of iframes which was popularized by Microsoft Internet Explorer 3.0 and is now supported by Netscape 6 and opera 5. An iframe is an inline frame that is not bound to the side of the browser window. It floats free and can sit anywhere in the window. It goes where it wants to go and displays whatever it needs to display. It obviously gives the web designer some undreamed of advantages. The next kind of page layout that is often used is the Style based layout. All style information is stored in a separate style sheet and <div> tags are used to place elements in right positions. By itself, the <div> tag is inert. It becomes active when it is combined with a style sheet rule. Most of these sheets use CSS positioning techniques to place their elements on the page—especially relative positioning. However, special effects can be obtained by using Floating boxes or Absolute Positioning techniques.  Layering is another method that is used during page layout to place elements on the page so that users have easy access to them. This type of layout is done sometimes deliberately to create dramatic effects. When overlapping layers are used the designer must inform the browser how the element goes into the z-index and which elements are high on the z index and which are lower. Well we have briefly explored the elements of the page, the size of the page the layout of the page and positioning of elements, generally, in the context. The chapters preceding this one and including this one was intended to be introductory. The idea was to ensure that you had all the concepts in place and that you truly appreciate the problems of the web designer who sets out to design his web page. Well we shall now begin drilling into each of the concepts in the context of absolute positioning of elements in the later chapters of this book.           Saturday, January 6. 2007
Site Organization and Element ... Posted by Steve Monas
in Chap 07 at
01:29
Comments (0) Trackbacks (0) Site Organization and Element Positioning
Site Organization and Element Positioning The user visiting a web site wants to find something. You as the designer must make it easy for him to do so. If the user leaves the site without finding the element he is looking for, you as a designer have failed to deliver. The positioning of the navigation elements and other elements on the site directs the user to the element he wants to find. A number of site organization models have been developed to assist web designers create usable and navigable web sites. In this chapter we shall briefly look at some of the organization models that are in use today. Logical site organization models. An efficient ordering of information is what users are looking for. Real content should be tucked away only a few clicks below the surface.  The information can be simply placed in a sequence or in hierarchies. Web like organizational structures have several advantages, but tend to develop into dense links that explore information nuggets fully from multiple dimensions.   Site diagrams are used to evolve the site and act as the core-planning document that is referenced every time a change is proposed. Positioning of the different elements on the web pages and the location, accessibility of the pages is defined in this document. Clear, consistent icons, graphic identity schemes and graphics or text based overview and summary screens can give the user a bird’s eye view of what he is looking for. Users should not be confronted with complexity. Interface metaphors should not be obscure or culturally insensitive. It is of paramount importance that users should always be able to return to the hom |