Web Design With CSS
Web Design With CSS
AMELITA M. SANTOS
(Faculty, School of Computer Science, Arellano University)
interconnected computers talking to one another. The computers (on the web) are typically connected by phone lines, digital satellite signals, cables, and other types of data-transfer mechanisms. A 'data-transfer mechanism' is a nerd's way of saying: a way to move information from point A to point B to point C and so on. The computers that make up the web can be connected all the time (24/7), or they can be connected only periodically. The computers that are connected all the time are typically called a 'server'. Servers are computers just like the one you're using now to read this article, with one major difference, they have a special software installed called 'server' software.
Web Design
The skill of designing hypertext presentations of content that is delivered to an end-user through the World Wide Web. The process of designing Web pages, Web sites, Web applications or multimedia for the Web and may utilize multiple disciplines, such as animation, authoring, graphic design, human-computer interaction, interaction design, photography, and search engine.
Technologies Involved
Markup languages (such as HTML, XHTML and
XML) Style sheet languages (such as CSS and XSL) Client-side scripting (such as JavaScript and VBScript) Server-side scripting (such as PHP and ASP) Database technologies (such as MySQL) Multimedia technologies (such as Flash and Silverlight)
A style sheet language is a computer language used to describe the presentation of structured documents.
A structured document is a document whose
sections are clearly defined and categorized (also called "well-formed"). A program presenting the document can present it in different styles because the content has been categorized.
One modern style sheet language with widespread use is CSS (Cascading Style Sheets) , which is used to style documents written in HTML, or XHTML and other markup languages.
What is CSS???
CSS is the acronym for: Cascading Style Sheets CSS is an extension to basic HTML that allows you to style your web pages. Style sheets let you place things exactly where you want them to be on the page, using the distance in pixels from the top and the left of the browser window.
Styles define how to display HTML elements Styles are normally stored in Style Sheets External Style Sheets can save you a lot of work External Style Sheets are stored in CSS files Multiple style definitions will cascade into one
Advantages of CSS
CSS is an excellent addition to plain HTML.
With plain HTML you define the colors and sizes of text and tables throughout your pages. If you want to change a certain element you will therefore have to work your way through the document and change it.
With CSS you define the colors and sizes in "styles". As you styles write your documents you refer to the styles. Thus, if you change a certain style it will change the look of your entire site. CSS offers much more detailed attributes than plain HTML for defining the look and feel of your site. Finally, CSS can be written so the user will only need to download it once - in the external style sheet document. When surfing the rest of your site the CSS will be cached on the users computer, and therefore speed up the loading time.
browsers (like FireFox and Internet Explorer) how to display things on a page. For example:
make text bold. position things a page. set the font style for a page or paragraph etc.
HTML file
<html> <head> A sample HTML </head> <body> <h1>A simple HTML structure <br><br>This is header 1 </h1> <h2>This is header 2</h2> <p>This is a paragraph</p>
Using Style
Styles are set by adding the TAG:
<STYLE ...>
This
CSS Syntax
The CSS syntax is made up of three parts:
1. a selector 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.
CSS Syntax
Note: If the value is multiple words, put quotes around the
value: p {font-family: "sans serif"} Note: If you wish 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} Note: 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 by separating each
selector with a comma. In the example below we have grouped all the header elements.
All odd header elements will be displayed in green
text color: h1,h3,h5 { color: green } All even header elements will be displayed in green text color: h2,h4,h6 { color: yellow}
CSS Syntax
Note: To apply more than one class per given
element, the syntax is: <p class="center bold"> This is a paragraph. </p> The paragraph above will be styled by the class "center" AND the class "bold".
You can also omit the tag name in the selector to
define a style that will be used by all HTML elements that have a certain class. In the example below, all HTML elements with class="center" will be centeraligned: .center {text-align: center}
CSS Style
In the code below both the h1 element and the p
element have class="center". This means that both elements will follow the rules in the ".center" selector: <h1 class="center"> This heading will be center-aligned </h1> <p class="center"> This paragraph will also be center-aligned. </p>
with particular attributes. The style rule below will match all input elements that have a type attribute with a value of "text":
The ID Selector
You can also define styles for HTML elements
with the id selector. The id selector is defined as a #. The style rule below will match the element that has an id attribute with a value of "green":
#green {color: green}
format the document according to it. There are three ways of inserting a style sheet:
many pages. With an external style sheet, you can change the look of an entire Web site by changing one file.
has a unique style. You define internal styles in the head section by using the <style> tag.
3. Inline Styles
An inline style loses many of the advantages of style sheets by
mixing content with presentation. Use this method sparingly, such as when a style is to be applied to a single occurrence of an element.
using the <link> tag. The <link> tag goes inside the head section:
<head> <link rel="stylesheet"
definitions from the file mystyle.css, and format the document according to it.
the entire site in one place, giving your site a consistent look across all the pages.
You must create a text file called mystyles.css. Type the styles code below into the file. Notice that this code does not have the <STYLE ...> tag in it: H2 { color:red; font-weight:900; font-family:sans-serif; }
Example
html File
w/ external CSS
<head> <style type="text/css"> hr {color: sienna} p {margin-left: 20px} body {background-image: url("images/ back40.gif")} </style> </head>
an old browser that does not support styles, will ignore the <style> tag, but the content of the <style> tag will be displayed on the page.
It is possible to prevent an old browser from displaying the content by hiding it in the HTML comment element:
<head> <style type="text/css> <!-- hr {color: sienna} p {margin-left: 20px} body { background-image: url("images/back40.gif") } --> </style> </head>
C. Inline Styles
To use inline styles you use the style attribute in the
relevant tag. The style attribute can contain any CSS property. The example below shows how to change the color and the left margin of a paragraph:
<p style="color: sienna; margin-left: 20px"> This is a paragraph </p>
adding style="styledefinition:styleattribute;" to the tags. Single tag CSS is used when the style is used in a
single place on the entire site.
Look at this example:
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 }
CSS Layers
With CSS, it is
possible to work with layers: pieces of HTML that are placed on top of the regular page with pixel precision.
http://www.echoecho.com/csslayers.htm