Professional Documents
Culture Documents
Cascading Style Sheet Webtool
Cascading Style Sheet Webtool
_______________
A Thesis
Presented to the
Faculty of
_______________
In Partial Fulfillment
Master of Science
in
Computer Science
_______________
by
Kalthoum Y. Adam
Summer 2011
iii
Copyright © 2011
by
Kalthoum Y. Adam
DEDICATION
Cascading Style Sheet (CSS) is a style language that separates the style of a web
document from its content. It is used to customize the layout and control the appearance of
web pages written by markup languages. CSS saves time while developing the web page by
applying the same layout and style to all pages in the website. Furthermore, it makes the
website easy to maintain by just editing one file.
In this thesis, we developed a CSS web tool that is intended to web developers who
will hand-code their HTML and CSS to have a complete control over the web page layout
and style. The tool is a form wizard that helps developers through a user-friendly interface to
create a website template with a valid CSS and XHTML code.
vi
TABLE OF CONTENTS
PAGE
ABSTRACT...............................................................................................................................v
ACKNOWLEDGEMENTS.......................................................................................................x
CHAPTER
1 INTRODUCTION .........................................................................................................1
1.3 Motivation..........................................................................................................2
4.2.3 JavaScript................................................................................................21
BIBLIOGRAPHY....................................................................................................................31
APPENDIX
ABBREVIATIONS .....................................................................................................33
viii
LIST OF TABLES
PAGE
LIST OF FIGURES
PAGE
ACKNOWLEDGEMENTS
My grateful gratitude goes to my Professor Alan Riggins for his generous
encouragement and guidance. Without his support I wouldn't have finished my project. My
special thanks to committee members, Dr. Carl Eckberg and Dr. Roxana Smarandache, for
CHAPTER 1
INTRODUCTION
The number of the Internet users is increasing rapidly. Many people use the Internet
as their main source of knowledge, communication, and online shopping. Recent statistics
show that 1.96 billion of the world's population is using the Internet as of June 30, 2010 [1].
1.1 BACKGROUND
A web page document consists of two different components. The first part is the
content of the web page document, which has the information that is presented to the visitors.
The information comes in the form of texts, images, videos, or sounds. This part is written by
using Markup language such as eXtensible HyperText Markup Language (XHTML) and
HyperText Markup Language (HTML) which defines the structure of the document (see
Appendix for a list of abbreviations). The second part is the presentation of the document
which controls how the elements in the document are displayed such as the font, background,
and paragraph. This part is written by Cascading Style Sheet (CSS) language, which is a
technique to customize the web pages' layout and control their appearance.
In this project, a cascading style sheet web tool is developed. The main function of
this tool is to create a CSS file and its corresponding XHTML file through a user-friendly
wizard.
2
task. In addition to these applications, there are plenty of tools and utilities that help
developers to do specific tasks. These applications and tools give users an opportunity to
attain a better outcome and enrich the quality of the products with less time and effort.
CSS is a great technique that helps to define the layout and appearance of a website.
Therefore, CSS generator is a practical tool that aids web developers in the web design
process, especially those who write their own code using text editors.
The main objective of this thesis is to explain the importance of Cascading Style
Sheets, how this technique works, and its implications in the web design cycle. This thesis
will also present the CSS tool and the techniques that are used to build it.
1.3 MOTIVATION
Web page layout is an issue that many web designers face. It is often a challenging
task to build a layout that works perfectly with different browsers without adding codes or
using tools. Moreover, most CSS generator tools and applications are either too complex to
The CSS generator tool is a simple and effective web tool to help web developers
who will hand code CSS and XHTML to have better control over the web page.
history, and structure is discussed. The following sections will cover markup languages and
Chapter three is a review of some related projects in the web design field. In the first
section, the difference between tool and application is explained. The next sections will
examine some applications and tools that contribute in the website development.
Chapter four will discuss the CSS web tool project and its features. In addition, the
author will demonstrate the technologies that are used to develop this tool.
Chapter five emphasizes the tests that are conducted during tool development and the
The last chapter contains the conclusion as well as future improvements of the CSS
web tool.
4
CHAPTER 2
Markup Language (SGML), Cascading Style Sheets were introduced later to clearly
CSS, HTML, and XHTML are maintained and controlled by the World Wide Web
Consortium (W3C). There are several levels of CSS. Each of them becomes a new version of
the previous one by adding new features and capabilities. The first one was CSS1, which was
possesses new ones. Examples of this are element positioning, visual formatting, and media
types. This version was first introduced in 1998. An update to CSS2 was published in 2002 to
CSS3 is the latest level which comes with a different approach than was introduced in
the last two levels. This level divides the style sheet specifications into small modules instead
of a single large one. This division helps in developing web browsers that are more efficient
to produce a distinguishable version of that text. Markup languages specify the code for the
structure and presentation of the document. HTML and XHTML are markup languages that
are used to tell web browsers how to structure and display web pages. [4]
developed for creating and sharing multimedia-enabled integrated electronic document over
the Internet. This was the birth of Hypertext Markup Language (HTML). HTML unified
authors' fragmented collections of pictures, sounds, and text under one document to facilitate
sharing. In addition to that, HTML enabled hypertext linking which automatically links
and usability of the language. The newer versions of HTML focus on the separation of the
presentation from its structure, improving accessibility features, and document rendering, as
introduced, a new version of HTML with XML was needed. EXtensible HyperText Markup
Language (XHTML) was first presented as a new version of HTML 4.0 using XML 1.0. [6]
XHTML syntax is similar to HTML. In spite of the similarity between the two
markup languages, there are some differences between them. XHTML has all the elements in
HTML 4.01, combined with the strict syntax of XML. Since XML is a markup language that
HTML. Elements in the XHTML document must be properly nested and closed. This is not
the case with HTML which not only allows for optional close tags, but also offers the use of
6
empty tags such line break <br> . [7] Since XHTML is a strict language, it is easier to
maintain, teach, and learn compared to HTML. XHTML is written in a precise code which
makes it more widely used in portable devices like cell phones, PDAs and other mobile
Let's look at an example of a markup code written by HTML and the same code in
XHTML:
<html>
<head>
<title>This is HTML example</title>
<body>
<h1>This is heading
<br>
<p><i>This is a paragraph</p></i>
<img alt=”image” src=”image.jpg”>
</body>
<html>
<head>
<title>This is XHTML example</title>
</head>
<body>
<h1>This is heading </h1>
<p><i>This is a paragraph </i></p>
<br />
<img alt=”image” src=”image.jpg” />
</body>
</html>
One major difference between HTML and XHTML is the DTD or DOCTYPE
statement. DTD stands for Document Type Definition and is used to specify which syntax is
used in the Web page. If you look at the source of an XHTML document the first thing you
There are three types 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"). The three DTD's look like this [8]:
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"> .
or print. CSS is a style sheet that is designed to enable the user with more control over the
The main purpose of CSS is to allow the separation of the (X)HTML webpage format
from its content by placing this format in a different file. By distinguishing the structure from
the presentation, we can easily standardize styles, designs, and layouts of all pages. Thus
providing the ability to maintain these pages in more flexible and efficient way.
There are three different ways to apply a cascading style sheets to (X)HTML
documents: external style sheets, internal style sheets, and inline styles.
Inline style means embedding the style in the body section of the document using a
style attribute. This type of styling is the least preferable by web developers for
implementing style due to the fact that it is less flexible and shifts away from the main
purpose of using CSS which is separating the style from content. However, this style is
8
useful when we need to apply a different style to the element in a single occurrence. In
Example of inline style : <h1 style = ”text-align: left” > some text </h1>. [9]
The second type is internal style sheet. This style is embedded in the header section of
the (X)HTML document. It is used when we need to apply a unique style to a single page in
the website. To apply the internal style, <style> tag is used after <head> tag. The following
<head>
<style type =”text/css”>
h1{ text-align:left;}
</style>
</head>
External style sheet is the third and the most recommended type for styling
documents. The style is placed in an external file which, facilitates changing the appearance
of all pages in the website by merely editing one file. The external file can be created using
any text editor and saved with .css extension. In the (X)HTML document we refer to the
external file in the header section of each page of the document. For example :
<head>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
More than one external style sheet can be used in the same document simply by
adding the reference of each style sheet after the head tag as in the example above.
Cascading means applying more than one style rule to a single element in the
document. This creates an order of precedence among rules. The highest level of precedence
that will be applied by the browser and lower ones will be ignored.
Although the inline style is the least preferable type, it has more precedence over
both external and internal style sheets when applying them to elements. Internal style sheet
9
comes in the second level and the external style sheet comes in the lowest level. This is
Ownership is another method of determining the order of precedence. The user of the
document has the highest level of precedence, the author comes next, and lastly the browser
rules, and each rule consists of selector and its declaration. The selector is the (X)HTML
element that we need to apply style to its properties. The declaration part contains the
property with the assigned value. Declaration can have more than one property separated by
a semicolon. The following is the syntax of a CSS rule: selector { property1 : value ;
property: value; … } , For example to set the body properties we could have the following
they write CSS. Different browsers possess different specifications, and even some elements
don't exist in one browser and exist in another. Elements occasionally appear different in
different browsers because some browsers don't support all properties. Furthermore, as
explained earlier, if the browser style sheet has a higher precedence for a certain element,
then that style is applied. But because browsers have different style sheet, the final outcome
will differ from one browser to another. This inconsistency in the appearance of the
document formatted by CSS forces web developers to test how the document looks in
different browsers before they deploy it. There are some techniques that are used to solve this
problem and some times more codes are added to the CSS file to overcome this issue.
different browsers. For instance, when we set the height to 100%, Internet Explorer stretches
the div to the content inside it. On the other hand, Firefox gives the full screen height to that
div. To solve this problem there are few different tricks. One of these is to simply set the
Figures 2.1 and 2.2 show how the same page appears in IE and Firefox.
11
Figure
Figure
2.12.1.
FireFox
FireFox
screen
screen
shotshot
for for
100%100%
height
height.
Figure
Figure
2.12.2.
FireFox
Internet
screen
Explorer
shot for
screen
100%shot
height
for 100% height.
12
CHAPTER 3
different types. An application contains many different parts that perform individual tasks
and work together to construct an entire system. This system works as one piece. On the
other hand, a software tool is either a single component of the software application that
serves specific function in the program, or it could be a small program that supports,
Software tools have great benefits to computers. They protect computers from
crashing, keep them running accurately, and make sure that memory is being used efficiently.
Another benefit of software tools is to protect important data for business and personal
computers. People often forget to save their data to other removable storage disks. Software
tools decrease the potential of losing important information and increase the performance of
World Wide Web. The final outcome is displayed to the public by web browser such as
Internet Explorer(IE), FireFox, Opera, Safari, and many other software. The content of the
website could be texts, images, audios, and videos. Contents could be static or interactive.
When you design a website, you should be aware of the basic aspects of design:
13
Web page content: The substance, and information you include in your site should be
related to the site and the area of the public that the website is concerned with.
The usability: Make your website user-friendly and easy to navigate.
The appearance: The graphics and text should include a single style that flows
throughout, to show consistency. The style should be professional, appealing and
relevant.
The structure: of the web site as a whole.[13]
The following applications create websites dynamically to users without necessarily
What-You-Get (WYSIWYG) web editor, which means the design you see in the screen is what
the visitors of the website will see. Dreamweaver has coding tools for HTML, XHTML,
XML, CSS ,and JavaScript. It also has a code editor where you can easily edit your code.
[14]
Although, this application is a powerful and rich, users need some time to get familiar
with its features. Another limitation in this application is the accessibility over the internet.
Since Dreamweaver is a desktop application, you should download it in order to use it. Not to
mention its price which is close to $ 400. Moreover, Dreamweaver is not supported in all
for creating standard-based websites with CSS based layout. Similar to Dreamweaver, this
supports XHTML with CSS. The User interface is similar to Adobe Dreamweaver.
need to learn this application and be familiar with it is features before using it. Although it’s
3.2.3 Amaya
Amaya is a W3C web editor and browser used to create a web-standard web page. It
is a free WYSIWYG web application. This app was developed to provide a framework that
can integrate with W3C technologies. It started with HTML and CSS, and it now supports
Amaya web editor has great features and is supported by Macintosh, Linux, Unix and
Windows. However since it is still free web app, there is a lot of stability and usability
available. These technologies spare the developer both time and effort to produce more
efficient websites.
There are many web design tools, each one of which does a specific task in the design
process. Some of the tools are free which make it even more convenient for developers.
1. Firebug: A free web development tool that comes as an extension of Firefox web
browser. This tool facilitates debugging and editing HTML and CSS. It also has a
Console for logging, analyzing and debugging JavaScript, and an inspection tool for
Document Object Model (DOM).
2. Web developer extension: Another great extension tool of Firefox web browser. It
helps with validating your XHTML document. It also facilitates debugging JavaScript
and CSS by displaying warnings and errors in the error console. This tool also fills
out web forms to help in testing. As well as having more functionality.
3. Google Web Toolkit (GWT): A free and open source tool that is used in building and
optimizing complex browser-based applications. The main function of this tool is to
help individuals with minimum experience in browser quirks, XMLHttpRequest, and
JavaScript. In addition, it is used to build productive and high-performance web
applications.
4. IE developer tool: The Microsoft version of Firefox web developer extension. It has
mainly the same features available in web developer tool. This tool is free for IE 6
and 7.
5. ColorZilla: A simple tool and very useful. It is an extension of Firefox browser and
used as an eyedropper, color picker and color palette browser.
16
CHAPTER 4
This chapter demonstrates the CSS web tool project and technologies that are used to
build it.
to build the form and the wizard in which the end-user can put his selection. In conjunction,
PHP script is used to process user selection and creates the CSS and XHTML files.
The wizard starts with specifying user's layout selection as shown in Figure 4.1.
Figure
Figure
4.1 Layout
4.1. Layout
screen
screen.
The first selection is a drop down menu for the Doctype of the XHTML file. There
are three options: Strict, Transitional, or Frameset. For more information about XHTML
17
doctype, refer to chapter 2. The second selection is the page alignment, i.e., full page,
centered page, or left aligned page. With the last two options the user can set the width of the
page compared to the full page. The third selection is the body background color, which is
selection is useful when the page alignment is center or left page alignment. The rest of the
selections are the website layout div elements. The wizard gives the user the option to choose
up to 3 columns and header and footer for the webpage. When the user check a selection, the
wizard will give options to set the height or width, and the background color of the div.
As shown in Figure 4.2, the options become visible when the check box is selected. In
The second dialog box in CSS wizard is for body properties. Figure 4.3 shows a
In body properties, the user can set the body background properties by choosing a
background image, selecting the position of the image and whether it is repeated or not.
Font properties have default values. User can change them to his own preference.
Link and heading are optional selections which expand for the user to provide more specific
options.
In the link selection, the user has the option to set the link state properties. The wizard
offers three state settings: the link state which is how the hyperlink text appears when page
18
first loaded, The visited state which is how it is displayed when hyperlink is clicked, and the
hover state which is how text appears when mouse hovers over the link. The default setting is
provided for each state, but the user always has the option to change them to his preferred
setting.
For heading, the user has the option to set h1 to h3 properties. Figure 4.4 shows the
The third dialog box is for setting the properties of paragraph and list in the columns.
Since the main column is always available, the selection for that div is always shown. For the
left and right columns, the selections to set their properties are shown if they are part of user
selection in the first dialog box. Otherwise their selection will be hidden by default. Figure
4.5 shows third dialog when the user selects to have two columns, main and left.
Users can expand the selections for column properties or can simply ignore them. If
(s)he chooses to set the properties for the paragraph and list, then the option will be available.
The default setting is provided and the user can change them.
19
Figure
Figure
4.44.4.
LinkLink
andand
Headings
headings
properties
properties.
Figure 4.6 shows the last step in CSS generator wizard. The user can still go back and
change insertions, or reset the whole wizard. If user is satisfied with insertions, then the
create button will execute the PHP script to build the output files. Output files are: the
XHTML file with doctype selection and divs of the layout selections, the CSS file which
include code correspondent to user insertions, and if user uploaded any image as a
background.
Figure 4.7 shows the output files where user can check them or save them.
4.2.1 XHTML
XHTML 1.0 transitional language was used to construct the webpage form wizard.
For more details about this markup language please refer to (section 2.3) in this thesis.
4.2.2 CSS
CSS stands for Cascading Style Sheets. CSS was used to style the form wizard. CSS
4.2.3 JavaScript
JavaScript is a scripting language which is used to add dynamic functionality to web
pages written by markup languages. It is a client-side language, that means it can run in the
which means it does not need a separate program to execute it. JavaScript code is embedded
within the XHTML/HTML document, so that when the page is loaded into the web browser,
language which means that you can use variables in the syntax for any type of data. This
element included are objects and their attributes are the properties. For example, to set the
22
background color of any element in the document using JavaScript we can access it by:
Many people confuse JavaScript language with Java. In fact, they are totally different
languages except for naming convention. The syntax of JavaScript code is similar to C. The
following is an example of simple JavaScript code for a button that gives message when it is
clicked:
<form>
<input type="button" onclick= "alert('Hello World')" value="Click Me">
</form>
In this project, JavaScript was used to make CSS form wizard more dynamic and
interactive with users. For example, the selection of checked boxes controls the presence of
the hidden options. When it is checked; more options are displayed which enables the user to
set them as was shown in Figure 4.2. As for columns selection, the checked check box
displays the column properties in the column properties section. JavaScript is also applied to
add some functionality to the reset function, such as resetting the color input box and hiding
4.2.4 JQuery
JQuery is a compact JavaScript Library that makes the HTML dynamic and adds cool
features on to it. It simplifies document traversing, event handling, animating and Ajax
interactions. Furthermore, JQuery enables developers to construct plugin with the JavaScript
To use JQuery you need first to add the JQuery library to your webpage, this is
simply done by adding the following line to the head section of the XHTML/HTML :
23
You can alternatively use hosted JQuery library from Google or Microsoft. The
following is an example of basic JQuery “hide method” to hide <p> element when button is
clicked [19]:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
JQuery is applied to build an interactive wizard from the regular XHTML form. This
will make it easier for the user to use the multi step form. Moreover, the user can go back to
change his entries before submitting them. JQuery color picker plugin was added to the
4.2.5 PHP
PHP stands for Hypertext Preprocessor. It is a server-side scripting language which
means that code is executed in the server and then sent to the client. PHP is used so widely in
web development for writing dynamically generated pages quickly. It can be embedded into
HTML code. PHP has a syntax influenced by C, Java, and Perl with some specific features.
[20]
24
PHP has some unique features that makes it preferable over other server-side
scripting. When it comes to performance, PHP scripts are faster. PHP is also portable
between platforms and runs in different operating systems. PHP syntax is clear and consistent
and that makes it a sophisticated and ease to use language. Additionally, it is an open source
project and it is supported by wide range different databases like MySQL, Oracle and
PHP can retrieve information passed by (X)HTML. And it can generate documents
In CSS wizard, information regarding user selections such as, XHTML doctype,
layout of the page, and properties of the elements are sent to PHP file in the server. PHP will
then process the information that are received to generate CSS and XHTML documents.
PHP scripts starts with <?php and ends with ?>. This is an example of simple php
<?php
echo “Hello World” ;
?>
25
CHAPTER 5
Testing was done through the development phase. It was applied with every single
element or functionality added to the tool. This helped to simplify the final test.
The CSS wizard was mainly developed in Mac OS. Mozilla FireFox 3.6.16 was used
to test and display the web tool during the development phase. Continued testing was applied
to check the web tool compatibility to different web browser like Safari, Internet Explorer
and Google Chrome. Furthermore, the CSS tool has been tested for platform compatibility
with Mac OS and Windows7 using the same web browsers. Another testing was applied to
check the output files. This was the most important test because it was the main objective of
building this tool. This test was conducted using two platforms, Mac OS and Windows7, and
the following web browsers: Mozilla FireFox 3.6.16, Safari 5.0.3, Internet Explorer 8.0 and
Google Chrome.
The following Figures show the output XHTML with the following inputs:
Page alignment is centered with 80% width, header is 50px height, left column is 20% width,
right column is 20% width, main column is 80% height and footer is 20px height.
The main column shows how the heading will appear in the website, left column and right
column show how both ordered and unordered lists look in these columns. Many properties
that user can still choose were not used in this testing.
26
CHAPTER 6
This Thesis presents the CSS generator wizard web tool as a helpful tool for web
developers who hand code the CSS and (X)HTML. As with any web tool, CSS wizard tool
saves both time and efforts by simply following easy steps to create the desired CSS and
XHTML files. This tool builds the website layout by enabling the user to choose the Doctype
for the XHTML webpage and the page structure. The page structure consists of number of
columns, header and footer. The user can specify the width and the height for the layout
structure. Then the user can set the properties of the body and columns of the website.
This work covers the most required CSS options by web developers. In future
versions, it can be improved to cover more options. For instance, in this version the
maximum number of columns which can be created by using this tool is three. Therefore,
The future versions can give more number of columns and layout options. Another
enhancement objective is to provide more properties for the columns such as tables and
forms. Menus also can be added as some developers could require it.
31
BIBLIOGRAPHY
[1] Internet World Stats. World Internet Usage Statistics News and World Population
Stats, n.d. http://www.internetworldstats.com/stats.htm, accessed: Apr. 9, 2011.
[2] XML UK: A Forum for SGML and XML Users and Developers. CSS History &
Information, 2008. http://www.xmluk.org/css-history-information.htm, accessed:
April. 9, 2011.
[3] P. Carey. New perspectives on HTML and XHTML. 5th ed., Cengage Learning,
Florence, KY, 2008.
[4] T. A. Powell. HTML & XHTML: The complete reference. 4th ed., McGraw-Hill
Osborne Media, New York, NY, 2003.
[5] C. Musciano and B. Kennedy. HTML & XHTML: The definitive guide. 6th ed.,
O'Reilly Media, Inc., Sebastopol, CA, 2006.
[6] W3Schools Online Web Tutorials. XHTML Tutorial, n.d.
http://www.w3schools.com/xhtml, accessed April 22, 2011.
[7] The Web Standards Project. HTML Versus XHTML, 2003.
http://www.webstandards.org/learn/articles/askw3c/oct2003/, accessed April 30,
2011.
[8] Htmlfixit.com. XHTML vs. HTML, n.d.
http://htmlfixit.com/tutes/tutorial_XHTML_and_HTML_-_The_differences.shtml,
accessed April 22, 2011.
[9] S. Collison. Beginning CSS web development: from novice to professional. Springer
Verlag New York, Inc., New York, NY, 2006.
[10] B. Wilson. What 'Cascading' Means. University of Toronto, n.d.
http://www.cs.toronto.edu/~darrell/csc104h/html/style/cascade.htm, accessed April
30, 2011.
[11] TutWow. Quick Tip: CSS 100% Height, 2008.
http://www.tutwow.com/htmlcss/quick-tip-css-100-height/, accessed May 14, 2011.
[12] Super Web Group. What Do Software Tools Do?, n.d.
http://www.superwebgroup.com/what-do-software-tools-do/, accessed April 24,
2011.
[13] Wikipedia. Web design, 2011. http://en.wikipedia.org/wiki/Web_design, accessed
April 24, 2011.
[14] Adobe. Web design software, HTML editor | Adobe Dreamweaver CS5.5, n.d.
http://www.adobe.com/products/dreamweaver.html, accessed May 9, 2011.
[15] World Wide Web Consortium (W3C). Amaya, 2010. http://www.w3.org/Amaya/,
accessed April 30 2011.
32
APPENDIX
ABBREVIATIONS
34
IE Internet Explorer