Gobohost.com

Contact US!
+12398105052

Website design and programming.

Intro to CSS (Part 2 of 5): CSS Rules

Sunday, February 17th, 2008

Continued from the series Intro to CSS.

Style Sheets
Properly used, style sheets can save you a lot of time and hassle.
Normally styling information is stored in an external file with the .css extension. Keeping this information is an external file comes in handy when changing the look of all pages in your website.

The 4 styling types and priority.
Generally speaking there are 4 areas that styling information can be found.

1. Browser default (Default style when no styling information is found.)
2. External style sheet (style.css)
3. Internal style sheet (Found inside the <head> tag.)
4. Inline style (Found inside a single HTML element.)

The greatest priority number in this list will override the other styling information. For example, if styling information is located in an external CSS file and also found inside the <head> of your page for the same element, then the information in the <head> will override the information found in the external style sheet.

The CSS syntax.

A basic line of CSS code would look like this: #menu { color: #ffffff; }

The syntax for CSS is made up of 3 parts.

1. Sector
2. Property
3. Value

Sector: Normally this is the HTML element or tag you wish to define. In our above example the sector would be #menu

Property: This is the attribute you are going to change. In our example the attribute we are changing is color.

Value: This is the value that you’re changing the attribute to. In our example the attribute for color is #ffffff(color white) NOTE: If a value contains multiple words, you must place it in quotations. Example, p {font-family: "sans serif"}

Comments.

Comments may be place inside a style sheet. This is very useful for making programming notes or debugging. Comments found in a style sheet are placed between ‘/*’ and ‘*/’ delimiters. Anything written inside the ‘/*’ and ‘*/’ is completed ignored by the browser.

Examples:

/* Start menu style */
#menu { color: #ffffff; }

Case-insensitive.

CSS is unaffected by upper or lower case code. However attributes not in control by CSS is. This includes URL’s, Font Names, HTML/XHTML attributes, and element/attribute names in XML. Generally CSS code is typed in all lower-case.
 

Intro to CSS (Part 1 of 5)

Sunday, February 10th, 2008

The term CSS stands for Cascading Style Sheets,

Originally HTML tags defined the content of a webpage. <table>, <p> and <h3> are some basic tags used to tell a browser how a page is supposed to be laid out.This worked well during the early stages of the internet. However, over time internet browsers continued to add new attributes to the original HTML specification. Although these new tags were a welcome change to old standards, it became more challenging to the programmer to properly organize their code and separate page content with layout.

CSS was design as a solution to this problem. CSS stands for Cascading Style Sheets and was created by the World Wide Web Consortium (W3C), a non profit origination responsible for standardizing the HTML language. Today every major browser supports CSS. This makes CSS ideal for programmers to maintain a uniform look and feel across deferent browsers.

What CSS does:

CSS defines how HTML elements are displayed in the browser. This information is usually stored in an external file with the .css file extension. The most common filename is style.css. CSS information can also reside on the HTML page as well but generally only done when just a small amount of styling is required. 

One major benefit of using external Cascading Style Sheets is that all pages of your website can reference one CSS file. This is very useful when making global changes to your site. For example, say you wanted to change the background color of your website. Instead of opening every page and changing the <background> tag you can just edit the #body property of your CSS file. Now every page on your website that references the style sheet will automatically change to reflect your new background color!
 

Search GBlog