+ Reply to Thread
Results 1 to 4 of 4

Thread: CSS Part 1: Introduction

  1. #1
    Lop
    Lop is offline
    Speaks fluent binary Lop has a spectacular aura about Lop has a spectacular aura about Lop's Avatar
    Join Date
    May 2006
    Posts
    1,179

    CSS Part 1: Introduction

    CSS Tutorial
    Chapter 1: Introduction to Cascading Style Sheets

    CSS is a form of style sheet language which is used to apply styles to HTML pages. It provides the capability to define styles like font, background, layout etc for various elements in a HTML document's presentation. One of the major advantages of CSS is that it allows for tableless web page design.

    CSS is a standard used for Web markup. The standard is set and maintained accross different versions by W3C, World Wide Web Consortium. The advantages of using Cascading Style Sheets for your webpages include

    Advantages
    1. Enforces a consistent look and feel to your entire web application
    2. Any change to your application's look, you just need to change the corresponding attribute in just one file (let's say a button's background) at one place, and Lo!, all the webpages now show up with the new color
    3. Good programming practice. By splitting design attributes from the elements (which usually have javascript to execute some business logic) you achieve good programming style.
    4. Wide array of style attributes


    However, CSS is not without its disadvantages, some of which include

    Disadvantages
    1. Browser incompatibilities. There are certain attributes which are exclusively supported only by Firefox, and there are some other which are supported only by IE.

    However, it will be a good idea to check for the corresponding attribute incompatibility if you are doubtful.
    Enough said, let us start with our first Hello World! CSS.

    Create a new html file with the following content Code:
    HTML Code:
    <html>
    
    <head>
    
    <style type="text/css">
        
        body 
        {
            background-color: lightblue;
        }
    
        h3
        {
            text-decoration: underline;
        }
    
    </style>
    
    <body>    
        <h3>Hello World!</h3>
    <body>
    </html>
    The output looks like the following:



    We write our Style attributes withing tag. The format of a writing a CSS attribute is given below

    HTML Code:
    selector 
    {
        property1: value1;
        property2: value2;
        ...
        propertyN: valueN;
    }
    where a selector can be any HTML tag on which we want to apply style attributes to. In the above example, we have applied style to body tag. The selector here is "body". And then we set the property, background-color to lightblue.

    After the body tag, we have applied style to heading 3, setting the attribute text-decoration to underline. There is also another method to apply style to HTML. Every HTML tag has an attribute style which can link to a style. Now imagine a scenario in which you have several heading3 tags. You want one particular H3 tag not to have its text underlined and want its font color to be maroon. We can override the style setting specified using the <style> </style> as follows

    HTML Code:
    <h3 style="color:red; text-decoration:none">I am special H3 tag</h3>
    The resulting HTML page would look like this:


    Please note that the above method is not considered very good practice in cases you don't need specialization of design. If you have a common design for all elements, it is always recommended to put them separately in within <style> tags. Now that we have seen how to develop and work with CSS, we now proceed to see Page Design using CSS
    Lop

  2. #2
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25

    Re: CSS Part 1: Introduction

    Nice tutorial Lop. I see you titled it "Part 1." Is it safe to assume you intend on writing more tutorials?

  3. #3
    Lop
    Lop is offline
    Speaks fluent binary Lop has a spectacular aura about Lop has a spectacular aura about Lop's Avatar
    Join Date
    May 2006
    Posts
    1,179

    Re: CSS Part 1: Introduction

    I do intend on writing some more tutorials, but I am unsure on what.
    Lop

  4. #4
    Code Slinger chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5 has a reputation beyond repute chili5's Avatar
    Join Date
    Mar 2008
    Posts
    7,023
    Blog Entries
    1

    Re: CSS Part 1: Introduction

    Excellent tutorial. I'm sure there's tons more that you can talk about with regards to CSS.

    Only one disadvantage for CSS?
    "Whenever you remember, I'll be there/
    Remember how we reached that dream together" - Carrie Underwood

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. ROBOT ASSEMBLY-- C language
    By hummer350 in forum C and C++
    Replies: 3
    Last Post: 07-31-2008, 10:03 PM
  2. Introduction -- Part 2
    By MeTh0Dz in forum Introductions
    Replies: 13
    Last Post: 07-23-2008, 07:08 PM
  3. Replies: 0
    Last Post: 05-05-2008, 07:43 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts