Affichage des articles dont le libellé est Tutorial CSS. Afficher tous les articles

How to create template whit Css / PDF


How to create template whit  Css / PDF







How to create template whit  Css / PDF




Table of Contents






Overview
Getting Started .
Web Page Creation Tips .
Creating a Basic Web Page Exercise .
Create a New Page .
Using a Table for the Layout .....
Adding Text ..
Adding Images ..
Adding Links ..
0

learning Cascading Style Sheets






Sample of the pdf document :








Cascading Style Sheets (CSS)




Cascading Style Sheets.  The name alone is enough to frighten many people away, conjuring up images of cryptic code and syntax, too difficult for the layperson to grasp.  In reality, however, CSS is one of the simplest and most convenient tools available to Web developers.  In this guide you will cover the basics of CSS, and see how it can be applied to simplify the task of managing a consistently formatted Web site with minimal headaches.


The Problem with HTML

CSS is a language for defining the formatting used in a Web site.  This includes things like colours, background images, fonts, margins, and indentation.  But you can do all that now with HTML tags, you might think.  So, why do we need CSS?  A very good question, and the best way to answer it is with an example of what is wrong with defining such styles using HTML.

A common design choice at present is to use a sans-serif font (like Arial, Verdana, Tahoma, etc.) for the main body text of a site.  Since most Web browsers default to a serif font like Times New Roman, creating a complex Web page layout using a sans-serif font will often involve a lot of <font> tags.  With the nested table layouts that have become commonplace on the Web, it would not be uncommon to see ten or twenty <font> tags simply dedicated to applying the same font to all of the text on the page.  Multiply this by 5 pages for a modest site and you could have around one hundred tags.  A bigger site might have 50 pages or more, in which case you are looking at a thousand <font> tags, all dedicated to applying that one basic, consistent style to the text of your document.

Just think how it would be if you had designed a site for a client and the client calls you late one Friday afternoon to say, “Arial is alright, but everyone uses it.  Let’s use Verdana instead.”  Fancy search-and-replace tools aside, you are now faced with the task of adjusting one hundred, one thousand, or even more <font> tags to make what, from your client’s perspective, may seem like a very simple change.  You can pretty much kiss the weekend you had planned goodbye.  Try not to groan out loud – it doesn’t go over well with most customers.

If you know your HTML, you may be thinking that the <basefont> tag, which lets you set the default font to be used throughout a page, provides a nice solution to this problem.  Even then, you’d have to adjust one tag for each page of your site.  Add another font style to the equation (maybe a different font for the menu bar), and the problem returns in full.

To this problem and others, Cascading Style Sheets are the solution.

Defining Styles with CSS

The basic principle of CSS is to allow the designer to define a style (a list of formatting details like fonts, sizes, and colours) and then apply it to one or more portions of one or more HTML pages using a selector.  Let’s look at a basic example to see how this is done.

Try out the following HTML code and view the results.

Certain aspects of the code need to be written as continuous, i.e. no paragraph breaks.  If using Notepad set the format for Word Wrap so as you do not have to keep scrolling left and right to read the code.  Notice that the code has been displayed in double line spacing EXCEPT where the code should be continuous (on a single line) this is displayed in normal or single line spacing.

<html>
<head>
<title> A simple page </title>
</head>
<body>
<h1><font face=”sans-serif” color=”#3366cc”>First Title</font></h1>
<p>...</p>
<h1><font face=”sans-serif” color=”#3366cc”>Second Title</font></h1>
<p>...</p>
<h1><font face=”sans-serif” color=”#3366cc”>Third Title</font></h1>
<p>...</p>
</body>
</html>

Save the file as css1.html

This document contains three headings, created using <h1> tags.  To make these headings stand out more, we have used <font> tags to make them light blue in a sans-serif font (Windows browsers will display them in Arial, for example).  Notice the repetition involved, even at this basic level.  We have had to specify the details of the font we wanted three separate times.  Wouldn’t it make sense to define the font just once and then apply it to all the headings?

Now try out the following page, this time using CSS, then view the results:

<html><head><title> A simple page </title><style type=”text/css”><!--h1 {font-family: sans-serif;color: #3366cc;}--></style></head><body><h1>First Title</h1><p>...</p><h1>Second Title</h1><p>...</p><h1>Third Title</h1><p>...</p></body></html> Save the file as css2.html
<style type=”text/css”>
  CSS Styles here
</style>
 
<style type=”text/css”>
<!--
  CSS Styles here
-->
</style>
 
h1 {
font-family: sans-serif;
color: #3366cc;
font-size: 72pt;
}
 
Remember to save the file as styles.css
 

All of the magic is between the <style> tags in the <head> of the document, where we define our light blue, sans-serif font and apply it to the <h1> tags in the document.  At this point don’t worry about the syntax; it will be explained in detail as we go on. 

Meanwhile, the <font> tags have completely disappeared from the <body>, leaving our document looking a lot less cluttered.

Changes to the style definition at the top of the page affect all three headings, and any other headings added to the page will also take on the style.

Now that we’ve got some idea of what CSS does, let’s look at the different ways of using CSS styles in our HTML documents.


Adding CSS Styles to HTML Documents

The simplest way of putting CSS styles in your Web pages is to use the <style> tag, as we did in the example above.  This lets you declare any number of CSS styles by placing them between the opening <style> tag and the closing </style> tag, as follows:

The TYPE attribute specifies the language that you’re using to define your styles.  CSS is the language we are going to use to define our pages and is indicated with the value text/css.  Another language you may come across is JavaScript Style Sheets (JSS), and is specified by text/javascript.

Since Web browsers are designed to ignore any tags they do not recognise, older browsers that don’t support CSS would normally output the CSS style definitions as plain text in the document.  To guard against this, it is common practice to enclose the style definitions within an HTML comment tag:

While nice and simple, the <style> tag has one major disadvantage.  Specifically, if you want to use a particular set of styles throughout your site, you’ll have to repeat those style definitions in a <style> tag at the top of every one of your site’s pages.

A more sensible alternative is to put those definitions in a plain text file (usually given a .css filename), and then link your documents to that one file.  Any changes to the style definitions in that one file will affect all pages that link to it.  This enables us to design our site with site-wide style definitions, our original objective.

To link a document to a CSS text file (say, styles.css), place a <link> tag in the document’s header:

<link rel=”stylesheet” type=”text/css” href=”styles.css”>

The next example calls upon a plain text file to define the documents style.  The code for the Web page is given below.

<html>
<head>
<title> A simple page </title>
<link rel=”stylesheet” type=”text/css” href=”styles.css”>
</head>
<body>
<h1>First Title</h1>
<p>I can place my first subject here.</p>
<h1>Second Title</h1>
<p>Information relating to my second heading goes here.</p>
<h1>Third Title</h1>
<p>This is where my third title text will be placed.</p>
<BR>
<a href = “http://www.itn.co.uk”>ITN</a>
<BR>
<a href = “http://www.bbc.co.uk”>BBC Home Page</a>
</body>
</html>

Save the file as css3.html
And the code for the styles.css file contains the style definition below:

Like an image file, you can reuse this styles.css file in as many pages as you need.  Not only will it save you typing, but it also ensures a consistent look to the headings across your entire site.......











 Click here for  Download PDF / FREE
           


0

Style Sheets / PDF






Sample of the pdf document :  






HTML has evolved into a mixed-up language: it defines logical structure-defining elements like lists, headlines, etc. together with pure formatting directives like <font>, <b>, and <i>. It is advantageous to separate those two:

  • ·         want to define logical structures for our content
  • ·         want to separately define formatting options for the structures
  • ·         want to be able to apply one set of formatting rules to multiple web pages for uniformity

That’s what (X)HTML + CSS (Cascading Style Sheets) accomplishes. Style sheets define how a text structure should look like, whereas (X)HTML defines where the structures start and end and how they are related. Styles sheets are cascading, because you can attach more than one style sheet to one (X)HTML document and they will all cascade into one style.

Styles can be defined in three different ways

·         external: the styles are define in a separate file, usually with .css extension
·         internal: the styles are defined inside the HTML file, usually in the header section
·         inline: the style is defined inside an existing tag

The most useful one is an external style sheet, so we will stick with that for the most part.
Each style in a style sheet has three parts, a selector, one or more properties with one or more values each, following this syntax:
selector {
   property1: value1 [value2 ...];
   property2: value1 [value2 ...];
   ...
}

To attach a style sheet to an external XHTML document you use the <link> tag in an HTML file. To attach a style sheet called style.css you would add the following to the head section of an XHTML document:
<link href="style.css" rel="stylesheet" type="text/css" />

Here is the framework for an XHTML – CSS document pair (the CSS style sheet is called style.css):
<!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>
<title>Title goes here</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<p>Content goes here</p>
</body>
</html>

While you can create style sheets with any text editor, it is convenient to use a more powerful editor specializing in web page creation – for example Expression Web:

Exercise:

Use Expression Web to create a new HTML document as well as a new style sheet and save the empty files to the same directory. Make the HTML document your current one, then use the “Format” menu to attach your new style sheet to your web page. Create a level-1 headline, a list, and a paragraph of text in your web document.
Check the source of your document to verify that Expression Web has inserted the correct framework and attached the right style sheet.
Define the following style, save everything, switch to your HTML document and press F5 to reload:
h1 {
      border: 2px black solid;
}

More about style sheets:

Style sheets define three types of styles:
#id                          ID’s are frequently used to define large structures in an HTML document. Each id can be used only once in each HTML document
.class                     Classes are styles that can be reused and applied to different elements via a class parameter, such as <p class=”name”> … </p>. The class=”name” parameter can be added to any HTML element. Multiple classes can be applied to one element by separating them with spaces, as in <p class=”name1 name2”>
element               Elements are used to redefine how existing  HTML elements are to be formatted

Common style properties are fonts, alignment, borders, margins, paddings, and locations. Here is a list of some common CSS properties (taken from http://www.htmldog.com/guides/) but there are additional ones....







 Click here for  Download PDF / FREE
    

0

Notes on CSS









Sample of the pdf document :  






Three CSS Styles
1.      Inline styles—inserted directed into html code
2.      Embedded or global styles—style defined for one document within the <head> tags
3.      Linked or external style sheets—a separate file called in one or several html documents

Inline Styles
<tag style=“attribute1:value1; attribute2:value2;…”>
e.g., <h1 style=“font-family:sans-serif; font-size:12; color:gold”>

Embedded Styles
Inserted within the head section of the html file:
<style>
h1 {font-family:sans-serif; font-size:18; color:gold}
p {font-family: serif; font-size:12}
</style>

External Style Sheet
1.      Use any text editor and open a new document.
2.      Type the style code, e.g.,
h1 {font-family:sans-serif; font-size:18; color:gold}
p {font-family: serif; font-size:12}
3.      Save your document as “filename.css.”

Linking to Style Sheets with the <link> Tag
In your html document where you want to apply the styles defined in the style sheet, insert the following code with the head section:
<link href=“filename.css” rel=“stylesheet” type=“text/css”>

Linking to Style Sheets with @import
To link to a style sheet within the embedded <style> tags:
<style>
@import url(filename.css);
other style declarations
</style>

To link to a style sheet within another style sheet:
@import url(filename.css);
other style declarations.......








 Click here for  Download PDF / FREE
                    



1

FREE CSS TUTORIAL / PDF






 


 


Sample of the pdf document :  






 

Cascading Style Sheets - Part I



 

CSS Elements:


The style specification is applied to elements. There are various ways of categorizing elements:
Replaced Elements
The contents of these elements are replaced by something else when it is rendered by the browser - like img or radio buttons in a form.
Nonreplaced Elements
The contents of these elements are rendered by the browser like p.
Block-level Elements
Block-level elements generate an element box that fills its parent element's content area and cannot have other elements at its sides. It generates breaks before and after the element box like p and div.
Inline-level Elements
Inline-elements generate a box within a line of text. They do not generate a break and can appear within the content of another element like span.

 

Structure of Style Sheet:


A style sheet is made up of comments and rules. Comments can be included using: /* ... */. Rules on the other hand have the following structure:
Selector {property1: value1; ... propertyn: valuen;}
A selector could be elements that we have already seen or we could define a separate class that we can apply to several elements. We could even have multiple selectors for a rule. Like:
Selector1, Selector2, .. {prop1: val1; ... propn: valn;}
One way of defining common style rules is to group them into a class and identify which elements they apply to. For example, if I wanted to make the header or the paragraph red if it were important but not otherwise I would do:
h1.important, p.important {color: red;}
To use this style for a particular header, the markup would look like:
<h1 class = "important"> ... </h1>
To apply the same class to all elements the asterisk symbol is used as a wildcard in the rule definition.
*.important {color: red;}
There are also id selectors. An id selector is a unique identifier and must occur only once in the xhtml document, whereas the class style maybe used several times.
In the XHTML document:
<h1 id = "veryImportant"> ... </h1>
In the Style Sheet:
#veryImportant {background: black; color: red;}



Document Structure



There is a structure to each xhtml document. Each xhtml element can be represented by the nodes in a tree. Every element is either a child or a parent element or both. We say there is parent-child relation if the difference in the levels is one. However, if the difference in the levels is one or more the relationship is called ancestor-descendant.

Cascading style sheets allows the user to define descendant selectors and even combine them:
h1 em, p strong {color: purple;}
Notice the absence of commas between ancestors and descendants. To select children use the following syntax:
h1 > strong {color: red;}
Adjacent siblings can also be selected. The following rule states: select a paragraph that immediately follows a header and remove the top margin.
h1 + p {margin-top: 0;}


 

Why Cascading?



Why the term cascading style sheets? One can include (import) several style sheets within an xhtml document. The rules are combined. Conflicting rules are resolved. Combining and resolving conflicting rules is the process that is called cascading. The conditions by each conflicting rules are resolved are not in themselves very complicated but are beyond the scope of our discussion.......







  Click here for  Download PDF / FREE




0

Tags