Beruflich Dokumente
Kultur Dokumente
Everywhere on the Web you will find pages that are formatted like newspaper pages using HTML columns.
Examples
Dividing a part of an HTML page into table columns is very easy to do. <html> <body>
<table border="0" width="100%" cellpadding="10"> <tr> <td width="50%" valign="top" bgcolor=red> This is some text. This is some text. This is some text. This is some text. This is some text. </td> <td width="50%" valign="top"> Another text. Another text. Another text. Another text. Another text. Another text. Another text. </td> </tr> </table> </body> </html>
HTML Frames
With frames, you can display more than one Web page in the same browser window.
Frames
With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and each frame is independent of the others. The disadvantages of using frames are:
The web developer must keep track of more HTML documents It is difficult to print the entire page
The <frameset> tag defines how to divide the window into frames Each frameset defines a set of rows or columns The values of the rows/columns indicate the amount of screen area each row/column will occupy
The <frame> tag defines what HTML document to put into each frame
In the example below we have a frameset with two columns. The first column is set to 25% of the width of the browser window. The second column is set to 75% of the width of the browser window. The HTML document "frame_a.htm" is put into the first column, and the HTML document "frame_b.htm" is put into the second column: <frameset cols="25%,75%"> <frame src="frame_a.htm"> <frame src="frame_b.htm"> </frameset> Note: The frameset column size value can also be set in pixels (cols="200,500"), and one of the columns can be set to use the remaining space (cols="25%,*").
Examples
Vertical frameset This example demonstrates how to make a vertical frameset with three different documents. <html> <frameset cols="25%,50%,25%"> <frame src="frame_a.htm"> <frame src="frame_b.htm"> <frame src="frame_c.htm"> </frameset> </html>
Horizontal frameset This example demonstrates how to make a horizontal frameset with three different documents. <html> <frameset rows="25%,50%,25%"> <frame src="frame_a.htm"> <frame src="frame_b.htm"> <frame src="frame_c.htm">
</frameset> </html>
Mixed frameset This example demonstrates how to make a frameset with three documents, and how to mix them in rows and columns. <html> <frameset rows="50%,50%"> <frame src="frame_a.htm"> <frameset cols="25%,75%"> <frame src="frame_b.htm"> <frame src="frame_c.htm"> </frameset> </frameset> </html>
Frameset with noresize="noresize" If a frame has visible borders, the user can resize it by dragging the border. To prevent a user from doing this, you can add noresize="noresize" to the <frame> tag. Add the <noframes> tag for browsers that do not support frames. This example demonstrates the noresize attribute. The frames are not resizable. Move the mouse over the borders between the frames and notice that you can not move the borders. <html> <frameset rows="50%,50%"> <frame noresize="noresize" src="frame_a.htm"> <frameset cols="25%,75%"> <frame noresize="noresize" src="frame_b.htm">
Navigation frame This example demonstrates how to make a navigation frame. The navigation frame contains a list of links with the second frame as the target. The file called "tryhtml_contents.htm" contains three links. <body style="background-color:yellow"> The source code of the links: <a href ="frame_a.htm" target ="showframe">Frame a</a><br> <a href ="frame_b.htm" target ="showframe">Frame b</a><br> <a href ="frame_c.htm" target ="showframe">Frame c</a> The second frame will show the linked document. <html> <frameset cols="120,*"> <frame src="try.html"> <frame src="frame_a.htm" name="showframe"> </frameset> </html>
Frame Tags
Tag <frameset> <frame> <noframes> <iframe> Description Defines a set of frames Defines a sub window (a frame) Defines a noframe section for browsers that do not handle frames Defines an inline sub window (frame)
CSS Introduction
What is CSS?
CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem External Style Sheets can save a lot of work External Style Sheets are stored in CSS files
CSS Syntax
Syntax
The CSS syntax is made up of three parts: a selector, a property and a value: selector {property:value} The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to change, and each property can take a value. The property and value are separated by a colon, and surrounded by curly braces: body {color:black} Note: If the value is multiple words, put quotes around the value: p {font-family:"sans serif"} Note: If you want to specify more than one property, you must separate each property with a semicolon. The example below shows how to define a center aligned paragraph, with a red text color: p {text-align:center;color:red} To make the style definitions more readable, you can describe one property on each line, like this: p { text-align:center; color:black; font-family:arial }
Grouping
You can group selectors. Separate each selector with a comma. In the example below we have grouped all the header elements. All header elements will be displayed in green text color: h1,h2,h3,h4,h5,h6 { color:green
input[type="text"] {background-color:blue}
CSS Comments
Comments are used to explain your code, and may help you when you edit the source code at a later date. A comment will be ignored by browsers. A CSS comment begins with "/*", and ends with "*/", like this: /*This is a comment*/ p { text-align:center; /*This is another comment*/ color:black; font-family:arial }
<html> <head> <link rel="stylesheet" type="text/css" href="ex1.css" /> </head> <body> <h1>This header is 36 pt</h1> <h2>This header is blue</h2> <p>This paragraph has a left margin of 50 pixels</p> </body> </html>
Inline Styles
An inline style should be used when a unique style is to be applied to a single occurrence of an element. To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph: <p style="color: red; margin-left: 20px"> This is a paragraph </p>
If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet. For example, an external style sheet has these properties for the h3 selector: h3 { color:red; text-align:left; font-size:8pt } And an internal style sheet has these properties for the h3 selector: h3 { text-align:right; font-size:20pt } If the page with the internal style sheet also links to the external style sheet the properties for h3 will be: color:red; text-align:right; font-size:20pt The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet.
inside an HTML element inside the head section of an HTML page in an external CSS file
Tip: Even multiple external style sheets can be referenced inside a single HTML document.
Cascading order - What style will be used when there is more than one style specified for an HTML element?
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority: 1. 2. 3. 4. Browser default External style sheet Internal style sheet (in the head section) Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style defined inside the <head> tag, or in an external style sheet, or in a browser (a default value). Note: If the link to the external style sheet is placed after the internal style sheet in HTML <head>, the external style sheet will override the internal style sheet!
CSS Background
CSS background properties are used to define the background effects of an element. CSS properties used for background effects:
Background Color
The background-color property specifies the background color of an element. The background color of a page is defined in the body selector:
Example
body {background-color:#b0c4de}
RGB - an RGB value, like "rgb(255,0,0)" Hex - a hex value, like "#ff0000"
In the example below, the h1, p, and div elements have different background colors:
Example
h1 {background-color:#6495ed} p {background-color:#e0ffff} div {background-color:#b0c4de}
Background Image
The background-image property specifies an image to use as the background of an element. By default, the image is repeated so it covers the entire element. The background image for a page can be set like this:
Example
body {background-image:url('paper.gif')}
Example
body { background-image:url('gradient2.png'); }
If the image is repeated only horizontally (repeat-x), the background will look better:
Example
body { background-image:url('gradient2.png'); background-repeat:repeat-x; }
Example
body { background-image:url('img_tree.png'); background-repeat:no-repeat; } In the example above, the background image is shown in the same place as the text. We want to change the position of the image, so that it does not disturb the text too much. The position of the image is specified by the background-position property:
Example
body { background-image:url('img_tree.png'); background-repeat:no-repeat; background-position:top right; }
To shorten the code, it is also possible to specify all the properties in one single property. This is called a shorthand property. The shorthand property for background is simply "background":
Example
body {background:#ffffff url('img_tree.png') no-repeat top right} When using the shorthand property the order of the property values are:
It does not matter if one of the property values are missing, as long as the ones that are present are in this order.
background-attachment
background-color
background-image
background-position
background image
background-repeat
top center top right center left center center center right bottom left bottom center bottom right x% y% xpos ypos inherit Sets if/how a background imagerepeat will be repeated repeat-x repeat-y no-repeat inherit
CSS Text
The CSS text properties define the appearance of text:
Text Color
The color property is used to set the color of the text. The color can be specified by:
name - a color name, like "red" RGB - an RGB value, like "rgb(255,0,0)" Hex - a hex value, like "#ff0000"
Example
body {color:blue} h1 {color:#00ff00} h2 {color:rgb(255,0,0)}
Text Alignment
The text-align property is used to set the horizontal alignment of a text. Text can be centered, or aligned to the left or right, or justified.
When text-align is set to "justify", each line is stretched so that every line has equal width, and the left and right margins are straight (like in magazines and newspapers).
Example
h1 {text-align:center} p.date {text-align:right} p.main {text-align:justify}
Text Decoration
The text-decoration property is used to set or remove decorations from text. The text-decoration property is mostly used to remove underlines from links for design purposes: It can also be used to decorate text:
Example
h1 {text-decoration:overline} h2 {text-decoration:line-through} h3 {text-decoration:underline} h4 {text-decoration:blink}
Text Transformation
The text-transform property is used to specify uppercase and lowercase letters in a text. It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word.
Example
p.uppercase {text-transform:uppercase} p.lowercase {text-transform:lowercase} p.capitalize {text-transform:capitalize}
Text Indentation
The text-indentation property is used to specify the indentation of the first line of a text.
Example
p {text-indent:50px} Specify the space between characters This example demonstrates how to increase or decrease the space between characters. <html> <head> <style type="text/css"> h1 {letter-spacing:2px} h2 {letter-spacing:-3px} </style> </head> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> </body> </html> Specify the space between lines This example demonstrates how to specify the space between the lines in a paragraph. <html> <head> <style type="text/css"> p.small {line-height: 90%} p.big {line-height: 200%} </style> </head> <body> <p> This is a paragraph with a standard line-height. The default line height in most browsers is about 110% to 120%. This is a paragraph with a standard line-height. </p> <p class="small"> This is a paragraph with a smaller line-height. This is a paragraph with a smaller line-height. This is a paragraph with a smaller line-height. </p>
<p class="big"> This is a paragraph with a bigger line-height. This is a paragraph with a bigger line-height. This is a paragraph with a bigger line-height. </p> </body> </html> Increase the white space between words This example demonstrates how to increase the white space between words in a paragraph. <html> <head> <style type="text/css"> p { word-spacing:30px; } </style> </head> <body> <p> This is some text. This is some text. </p> </body> </html>