All in one forum  - Applications | Games | E-Books | Music, Movies & Videos | Mobile Stuff | Live Discussions | Webmaster Stuff | Many More | Community to Hang Out & Stick to One low monthly fee you get access to files using 4 premium accounts

Unlimited Storage and Bandwidth for $4.95/mo Your Link here @20$ Member of the Month - Free Rapidshare Account Join NFO Competition
Go Back   Home > Tutorial Section > Programming > CSS and XML
Forgot Password? Join Us!

Notices

Your Ad Here


Post New Thread Reply
 
LinkBack Thread Tools Display Modes
Old 06-14-2008, 06:41 AM   #1 (permalink)
 
KoOL's Avatar

 
User Info
Join Date: Oct 2007
Location: In Your Mind
Age: 27
Achievements Posts: 11,081
Casino Cash: $1187430

Total Points: 239,825,819,468.72
Donate

KoOL has disabled reputation

Awards Showcase
Administrator Of the Month Of Jan 
Total Awards: 1
Introduction To CSS

Have you’ve been stuck on designing your site using Dreamweaver or some other WYSIWYG (What You See Is What You Get) web page maker? If you’re ready to step out of the shadows of table based layouts, and discover CSS design then this article is for you. This article doesn’t aim to give you CSS code that you can copy to put on your website, instead teach you about the nuances you wouldn’t find in a general CSS tutorial or code.
What exactly is CSS?

CSS stands for cascading style sheets. Ok, what does that mean? Look at it like this, XHTML contains the data/content to display, CSS decides how the content looks, and Javascript determines how the web page interacts. CSS provides not only structure to the web page like a table would but also stylization the content like background color and font size.
CSS goes hand in hand with HTML. If you’ve used Dreamweaver or a similar application, then just learning CSS won’t help you that much. While you might be able to fly by the seat of your pants, learning & knowing HTML will prove to be vital. Clean and valid HTML will not satisfy avid web designers, it will save you tons of time when your design breaks and doesn’t look right. This article won’t delve into each attribute, instead the best practices of implementing attributes to the elements of the web page.
How to apply attributes to different elements

Attributes are instructions of how elements in the HTML should look. Attributes can be anything from font-size to background-color, but this section describes how to effectively apply certain attributes to different elements.
  • ID’s
    ID tags in HTML (<div id=”header”>) are tags which should only be used once per web page. Generally, you want to use an ID to denote the page structure, so you might have id’s for a web page of “header”, “content”, “sidebar” and “footer”, because you’re not going to have two headers or two footers for any one webpage. To assign a style to an ID tag in CSS, use: #idtagname{
    /* assign attributes here */
    }
  • Class
    Unlike ID tags, class tags can be used multiple times. This is great when you want different parts of the design to look the same.
    To assign a style to a class tag in CSS use: .classname{
    /* assign attributes here */
    }
  • HTML elements
    You can apply a style to a particular HTML tag with CSS without using an id or class. For example, if you wanted to change every list (ul) to change from a dot to a square, you could simply do: li{
    list-style:square;
    }
    Generally you don’t want to apply a style to an element like this. One exception though would be the body tag because it only appears once. In the next paragraph though, you will see where using the general HTML element is appropriate.
  • Combining All Three
    If you’ve played around with CSS before, you’ve probably created HTML like this: <ul>
    <li class=”x”></li>
    <li class=”x”></li>
    <li class=”x”></li>
    <li class=”x”></li>
    </ul>
    If you have a lot of li elements, you’ll know it can get very annoying to type out class=”x” every time. But there is a way to simplify this. Instead use the following CSS,
    .y li{
    /* CSS attributes for class x here */
    }
    And your HTML can become this:
    <ul class=”y”>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    </ul>
    The CSS applies the attributes for define in “.y li” for the li elements embedded in class “y”. Thus you get a cascading effect where you can affect elements inside certain elements. You can use this cascading affect for any combination of ID’s, class and elements. For example, you might use:
    #content .post ul{ /* style attributes here */}
Print vs Screen

Believe it or not, you can create a CSS for when someone prints out a web page which is great for a visitor because usually if you print you just want the primary content. Generally, you want a very different style sheet as compared to the “screen” version. Using the attribute “display: none;” you can and should get ride of ads, a sidebar and any other information someone wouldn’t want to print out. You also want a black text on white background design, otherwise you’ll make people print too much ink.
You link to the print CSS file almost exactly the same except for the ‘ media=”print” ‘ part.
<link rel=”stylesheet” href=”style.css” type=”text/css” media=”screen” /> <!– for browser –> <link rel=”stylesheet” href=”print.css” type=”text/css” media=”print” /> <!– for printer –>

CSS Default

When you load your HTML file in any web browser whether it be Firefox, Internet Explorer or Safari, the browser will render the web page with certain style attributes already assigned. You can of course override these attributes with CSS, but if you don’t specify differently, the browser will render the page with certain attributes already applied. Each web browser has subtle difference in how they render a web page under defaults, but in general a web page will look the same.
For example, the dots for a list item or the font family is a default style of the browser. You have the power to make that dot into a square or that font from Times New Roman to Verdana. But if you don’t specify, the browser will assume it. Another default attribute that always fools a beginner is the body tag which has a margin.
Save lines of code, be efficient

From time to time, you’ll notice your coping and pasting attributes from one id or class to another. If you find yourself applying the same attributes to a few elements, then you can combine attribute assignments so that multiple classes, ids and elements share the attributes. Lets take the attributes for the left and right arrows on the javascript image gallery. I originally had this as the attributes:

#moveleft{
margin:0px;
height:58px;
color: white;
width: 16px;
text-indent: -2000em;
text-decoration: none;
z-index: 1000;
display:block;
cursor: pointer;
float:left;
background: url(’left.gif’);
}

#moveright{
margin:0px;
height:58px;
color: white;
width: 16px;
text-indent: -2000em;
text-decoration: none;
z-index: 1000;
display:block;
cursor: pointer;
float:left;
background: url(’right.gif’);
}
This is silly though because the two are essentially duplicates of each other except for the background image. We can though apply one set of attributes to both ids (using a comma to include more elements) and set the background to their respective urls:
#moveleft, #moveright{
margin:0px;
height:58px;
color: white;
width: 16px;
text-indent: -2000em;
text-decoration: none;
z-index: 1000;
display:block;
cursor: pointer;
float:left;
}
#moveleft{background: url(’left.gif’);}
#moveright{background: url(’right.gif’);}

Conclusion

The mark of a good CSS designer is one that creates the CSS for the HTML. If you start designing your HTML around what you can do with the CSS, you still have more to learn. In the future, I’ll delve into the basics of taking a design in Photoshop into HTML web page. If you have any questions or sub-topics you would like me to discuss, please leave a comment below.


For Download Links U need to Press Thanks Button

Please don't PM me For Posts, Request and Not Working Threads. Use Button.
KoOL is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply
Click here to Donate to remove the Adverts.
Post New Thread Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Introduction to XML KoOL CSS and XML 1 11-11-2008 09:54 AM
Self Introduction imkumar Introduction Zone. 1 03-17-2008 06:26 AM
Introduction suk Introduction Zone. 1 02-20-2008 12:56 PM
Introduction cinome Introduction Zone. 1 02-06-2008 06:49 PM
[vid]Introduction To TOR hacks Ebooks,tutorials & Other Stuff 0 11-29-2007 03:46 AM


These are the 125 most used thread tags
Tag Cloud
(2008) 1080i 2007 2008 2009 action adobe adventure aio antivirus appz audio avalon avira backgrounds beta black build burning collection comedy converter copy crack database deluxe desktop development digital tutors direct download disciple download download manager drama driver dvdrip easy edition files final finance flash fonts free full funny game games getdata graphics guide hacking hdtv hidden high hq increditools internet introducing myself kaspersky keygen link love magic manager matlab maya media megaupload microsoft mobile movie multimedia music n95 nero network office pack photoshop pictures pillar platinum plumb pocket portable premium professional quality rapidshare recover retail ringtones rock rs.com security serial sexy smartmovie software soundtrack steppenwolf studio suite symbian telugu movie template thriller tools tutorial ultimate utilities video videos virus vista wallpaper wallpapers web development windows wwe xp xvid [2008] [rs.com]

New To AiO Forum? Need Help?

Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Site Best Viewed with Firefox 3.0 & IE v7.0
RapidShare Links PhazeDDL Warez
PhazeDDL Warez