Free Articles, Free Web Content, Reprint Articles
Monday, May 28, 2012
 
Free Articles, Free Web Content, Reprint ArticlesRegisterAll CategoriesTop AuthorsSubmit Article (Article Submission)ContactSubscribe Free Articles, Free Web Content, Reprint Articles
ADVERTISEMENTS
 

Introduction To Cascading Style Sheets

CSS ... Style Sheets) have been around for a while now,and act as a ... to plain old HTML files. Style ... a ... to separate HTML code from ... rulesand styles. It s

CSS (Cascading Style Sheets) have been around for a while now,
and act as a complement to plain old HTML files. Style sheets
allow a developer to separate HTML code from formatting rules
and styles. It seems like many HTML beginners’ under-estimate
the power and flexibility of the style sheet. In this article,
I’m going to describe what cascading style sheets are, their
benefits, and two ways to implement them.

---------------------------------------
Cascading whats?
---------------------------------------

Cascading Style Sheets…that’s what! They’re what paint is to
canvas, what topping is to ice cream… they complement HTML
and allow us to define the style (look and feel) for our entire
site in just one file!

Cascading style sheets were introduced to the web development
world way back in 1996. They get their name from the fact that
each different style declaration can be “cascaded” under the
one above it, forming a parent-child relationship between the
styles.

They were quickly standardized, and both Internet Explorer and
Netscape built their latest browser releases to match the CSS
standard (or, to match it as closely as they could).

So, you’re still asking what a style sheet exactly is? A style
sheet is a free-flowing document that can either be referenced
by, or included into a HTML document. Style sheets use blocks
of formatted code to define styles for existing HTML elements,
or new styles, called classes.

Style sheets can be used to change the height of some text, to
change the background color of a page, to set the default border
color of a table…the list goes on and on. Put simply though,
style sheets are used to set the formatting, color scheme and
style of an HTML page.

Style sheets should be used instead of the standard , ,
and tags because:

- One style sheet can be referenced from many pages, meaning
that each file is kept to a minimum size and only requires
only extra line to load the external style sheet file

- If you ever need to change any part of your sites look/feel,
it can be done quickly and only needs to be done in one
place: the style sheet.

- With cascading style sheets, there are many, many page
attributes that simply cannot be set without them:
individual tags can have different background colors,
borders, indents, shadows, etc.

Style sheets can either be inline (included as part of a HTML
document), or, referenced externally (Contained in a separate
file and referenced from the HTML document). Inline style sheets
are contained wholly within a HTML document and will only
change the look and layout of that HTML file.

Open your favorite text editor and enter the following code.
Save the file as stylesheet.html and open it in your browser:



Cascading Style Sheet Example < itle> <br> <style> <br> h1 <br> { <br> color: #636594; <br> font-family: Verdana; <br> size: 18pt; <br> }<br> </style> <br> </head> <br><body> <br> <h1>This is one big H1 tag!</h1> <br></body> <br></html> <br><br>When you fire up your browser, you should see the text "This is<br>one big H1 tag!" in a large, blue Verdana font face.<br><br>Let’s step through the style code step by step. Firstly, we have<br>a pretty standard HTML header. The page starts with the <html><br>tag followed by the <head> tag. Next, we use a standard <title><br>tag to set the title of the page we are working with. <br><br>Notice, though, that before the <head> tag is closed, we have<br>our <style> tag, its contents, and then the closing </style> tag.<br><br><style> <br> h1 <br> { <br> color: #636594; <br> font-family: Verdana; <br> size: 18pt; <br> } <br></style> <br><br>When you add the style sheet code inline (as part of the HTML<br>document), it must be bound by <style> and </style> tags<br>respectively. Our example is working with the <h1> tag. We are<br>changing three attributes of the <h1>’s style: the text color<br>(color), the font that any <h1> tags on the page will be<br>displayed in (font-family), and lastly, the size of the font<br>(size). <br><br>The code between the { and } are known as the attributes. Our<br>sample code has three. Try changing the hexadecimal value of<br>the color attribute to #A00808 and then save and refresh the<br>page. You should see the same text, just coloured red instead<br>of blue.<br><br>---------------------------------------<br>An example of an external style sheet<br>---------------------------------------<br><br>External style sheets are similar to internal style sheets,<br>however, they are stripped of the <style> and </style> tags,<br>and need to be referenced from another HTML file to be used. <br><br>Create a new file called “mystyle.css” and enter the following<br>code into it:<br><br>h1 <br>{ <br> color: #a00808; <br> font-family: Verdana; <br> size: 18pt <br>} <br><br>Next, create a HTML file and name it external.html. Enter the<br>following code into external.html:<br><br><html> <br> <head> <br> <title> External Style Sheet Reference Example < itle> <br> <link rel="stylesheet" type="text/css" href="mystyle.css"> <br> </head> <br> <body> <br> <h1>This is one big H1 tag!</h1> <br> </body> <br></html> <br><br>As mentioned above, you can see that the actual code in<br>mystyle.css is exactly the same as it was in the inline example.<br>In our HTML file, we simply place a <link> tag in the <head><br>section of our page. The rel=”stylesheet” attribute tells the<br>browser that the link to the external file is a style sheet.<br>The type=”text/css” attribute tells the browser that mystyle.css<br>is a text file containing css (cascading style sheet)<br>declarations. Lastly, the href=”mystyle.css” attribute tells<br>the browser that the actual file we want to load is mystyle.css. <br><br>---------------------------------------<br>Conclusion<br>---------------------------------------<br><br>Well, there you have it<a href="http://www.articlesfactory.com/articles/business.html"><img src="http://www.articlesfactory.com/pic/x.gif" alt="Business Management Articles" border="0"></a>, a quick look at style sheets and how<br>to implement both an inline and external version. Checkout the<br>links below if you’ve never worked with cascading style sheets<br>before. You will be surprised at some of the things you can do<br>with them! <br><br>- http://www.devarticles.com/art/1/7<br>- http://hotwired.lycos.com/webmonkey/98/15/index0a.html<br>- http://www.webreview.com/style/index.shtml<br>- http://jigsaw.w3.org/css-validator/ <p class="txt-small-regular"> Article Tags: <a href="http://www.articlesfactory.com/search/Cascading+Style+Sheets/" class="right-link">Cascading Style Sheets</a>, <a href="http://www.articlesfactory.com/search/Font-family%3A+Verdana%3B+Size%3A/" class="right-link">Font-family: Verdana; Size:</a>, <a href="http://www.articlesfactory.com/search/Cascading+Style/" class="right-link">Cascading Style</a>, <a href="http://www.articlesfactory.com/search/Style+Sheets/" class="right-link">Style Sheets</a>, <a href="http://www.articlesfactory.com/search/Style+Sheet/" class="right-link">Style Sheet</a>, <a href="http://www.articlesfactory.com/search/Referenced+From/" class="right-link">Referenced From</a>, <a href="http://www.articlesfactory.com/search/External+Style/" class="right-link">External Style</a>, <a href="http://www.articlesfactory.com/search/Html+File/" class="right-link">Html File</a>, <a href="http://www.articlesfactory.com/search/Font-family%3A+Verdana%3B/" class="right-link">Font-family: Verdana;</a>, <a href="http://www.articlesfactory.com/search/Verdana%3B+Size%3A/" class="right-link">Verdana; Size:</a> </p> <!-- google_ad_section_end --> <p class="txt-small-regular">Source: <a href="http://www.articlesfactory.com" class="small-link" title="Free Articles">Free Articles</a> from ArticlesFactory.com</p> <table> <tr> <td valign="top"><g:plusone size="medium" count="false"></g:plusone></td> <td valign="top"><div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div></td> <tr> </table> <p> <h1>ABOUT THE AUTHOR</h1> <br> <div>Mitchell is the founder and senior editor of<br>http://www.devarticles.com. DevArticles provides its readers<br>with top quality ASP, PHP and .NET articles, interviews and<br>product reviews. If you're looking for insider tips and tricks,<br>you'll also find them at DevArticles. You can visit DevArticles<br>by clicking on this link: http://www.devarticles.com.<br></div> </p> <center> <!-- ValueClick Media 300x250 Medium Rectangle CODE for articlesfactory.com --> <script language="javascript" src="http://media.fastclick.net/w/get.media?sid=20894&m=6&tp=8&d=j&t=n"></script> <noscript><a href="http://media.fastclick.net/w/click.here?sid=20894&m=6&c=1" target="_blank"> <img src="http://media.fastclick.net/w/get.media?sid=20894&m=6&tp=8&d=s&c=1" width=300 height=250 border=1></a></noscript> <!-- ValueClick Media 300x250 Medium Rectangle CODE for articlesfactory.com --> </center> <!-- Kontera ContentLink --> <SCRIPT LANGUAGE="JavaScript"> var dc_UnitID = 14; var dc_PublisherID = 3523; var dc_AdLinkColor = '#990000'; var dc_underlineType = 'solid'; var dc_open_new_win = 'yes'; var dc_adprod='ADL'; </SCRIPT> <SCRIPT LANGUAGE="JavaScript" SRC="http://kona.kontera.com/javascript/lib/KonaLibInline.js"></SCRIPT> <!-- Kontera ContentLink --> <br> <br> </div> </td> </tr> <tr> <td width="131" height="24" bgcolor="#EDE9E3" valign="top"> <table width="131" height="24" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/health.html" class="left-menu-inactive">Health</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/business.html" class="left-menu-inactive">Business</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/finance.html" class="left-menu-inactive">Finance</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/travel.html" class="left-menu-inactive">Travel</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/home-repair.html" class="left-menu-inactive">Home Repair</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/technology.html" class="left-menu-inactive">Technology</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/computers.html" class="left-menu-inactive">Computers</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/family.html" class="left-menu-inactive">Family</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/communication.html" class="left-menu-inactive">Communication</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/entertainment.html" class="left-menu-inactive">Entertainment</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/autos.html" class="left-menu-inactive">Autos</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/marketing.html" class="left-menu-inactive">Marketing</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/self-help.html" class="left-menu-inactive">Self Help</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/sports.html" class="left-menu-inactive">Sports</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/home-business.html" class="left-menu-inactive">Home Business</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/education.html" class="left-menu-inactive">Education</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/ecommerce.html" class="left-menu-inactive">ECommerce</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/law.html" class="left-menu-inactive">Law</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/other.html" class="left-menu-inactive">Other</a></td> </tr> <tr> <td height="24" background="http://www.articlesfactory.com/pic/left_menu_inactive.gif"><a href="http://www.articlesfactory.com/articles/internet.html" class="left-menu-inactive">Internet</a></td> </tr> </table> <table width="131" height="11" border="0" cellspacing="0" cellpadding="0" bgcolor="#EDE9E3"> <tr> <td height="11" align="right"><img src="http://www.articlesfactory.com/pic/right_curve.gif" width="12" height="11" alt="" border="0"></td> </tr> </table> <!-- google_ad_section_start(weight=ignore) --> <div class="left-section"><b>Partners</b></div> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="http://www.articlesfactory.com/pic/x.gif" width="15" height="1" alt="" border="0"></td> <td valign="top"><img src="http://www.articlesfactory.com/pic/left_menu_bullet.gif" width="8" height="10" alt="" border="0"></td> <td><div class="left-section-link"><a class="left-section-link" href="http://www.bailfish.com" target="_blank" rel="nofollow">California Bail Bonds Bounty Hunters</a></div></td> </tr> <tr> <td><img src="http://www.articlesfactory.com/pic/x.gif" width="15" height="1" alt="" border="0"></td> <td valign="top"><img src="http://www.articlesfactory.com/pic/left_menu_bullet.gif" width="8" height="10" alt="" border="0"></td> <td><div class="left-section-link"><a class="left-section-link" href="http://www.kateraynor.com" target="_blank" rel="nofollow">Immigration Attorney</a></div></td> </tr> <tr> <td><img src="http://www.articlesfactory.com/pic/x.gif" width="15" height="1" alt="" border="0"></td> <td valign="top"><img src="http://www.articlesfactory.com/pic/left_menu_bullet.gif" width="8" height="10" alt="" border="0"></td> <td><div class="left-section-link"><a class="left-section-link" href="http://www.movingcompanies.tv" target="_blank" rel="nofollow">Moving Relocation Services</a></div></td> </tr> <tr> <td><img src="http://www.articlesfactory.com/pic/x.gif" width="15" height="1" alt="" border="0"></td> <td valign="top"><img src="http://www.articlesfactory.com/pic/left_menu_bullet.gif" width="8" height="10" alt="" border="0"></td> <td><div class="left-section-link"><a class="left-section-link" href="http://www.diyawards.com" target="_blank" rel="nofollow">Crystal Awards and Trophies</a></div></td> </tr> <tr> <td><img src="http://www.articlesfactory.com/pic/x.gif" width="15" height="1" alt="" border="0"></td> <td valign="top"><img src="http://www.articlesfactory.com/pic/left_menu_bullet.gif" width="8" height="10" alt="" border="0"></td> <td><div class="left-section-link"><a class="left-section-link" href="http://janeshilton.co.uk/handbags" target="_blank" rel="nofollow">Handbags</a></div></td> </tr> <tr> <td><img src="http://www.articlesfactory.com/pic/x.gif" width="15" height="1" alt="" border="0"></td> <td valign="top"><img src="http://www.articlesfactory.com/pic/left_menu_bullet.gif" width="8" height="10" alt="" border="0"></td> <td><div class="left-section-link"><a class="left-section-link" href="http://caraudiosecurity.com/shop/home.html" target="_blank" rel="nofollow">Alpine Car Audio</a></div></td> </tr> <tr> <td><img src="http://www.articlesfactory.com/pic/x.gif" width="15" height="1" alt="" border="0"></td> <td valign="top"><img src="http://www.articlesfactory.com/pic/left_menu_bullet.gif" width="8" height="10" alt="" border="0"></td> <td><div class="left-section-link"><a class="left-section-link" href="http://www.citrusfresh.com" target="_blank" rel="nofollow">Carpet Cleaning Los Angeles</a></div></td> </tr> </table> <div align="center"> <script type="text/javascript"><!-- google_ad_client = "ca-pub-0003120597825310"; /* [AF] (120 x 600) */ google_ad_slot = "2900666160"; google_ad_width = 120; google_ad_height = 600; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> <br> <br> <!-- google_ad_section_end(weight=ignore) --> </td> </tr> </table> <table width="750" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td height="50"> <div class="small-link" align="center"> <a class="small-link" href="http://www.articlesfactory.com/">Free Articles Home</a> | <a class="small-link" href="http://www.articlesfactory.com/signup.html">Register</a> | <a class="small-link" href="http://www.articlesfactory.com/submit.html">Submit an Article</a> | <a class="small-link" href="http://www.articlesfactory.com/links.html">Links</a> | <a class="small-link" href="http://www.articlesfactory.com/contact.html">Contact</a> | <a class="small-link" href="http://www.articlesfactory.com/archive.html">Archive</a> | <a class="small-link" href="http://www.articlesfactory.com/rss.html"><img src="http://www.articlesfactory.com/pic/icon-xml-rss_red.gif" width="52" height="13" alt="XML/RSS Feed" border="0" align="middle"></a> </div> <div class="small-link" align="center"> <a class="small-link" href="http://www.articlesfactory.com/terms.html">Terms of Service</a> | <a class="small-link" href="http://www.articlesfactory.com/privacy.html">Privacy Policy</a> </div> </td> </tr> </table> <!-- Start of StatCounter Code --> <script type="text/javascript" language="javascript"> <!-- var sc_project=479039; var sc_invisible=1; var sc_partition=3; var sc_security=""; //--> </script> <script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><img src="http://c4.statcounter.com/counter.php?sc_project=479039&java=0&security=&invisible=1" alt="free web stats" border="0"></noscript> <!-- End of StatCounter Code --> <!-- Start of Google Analytics Code --> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-88528-1"; urchinTracker(); </script> <!-- End of Google Analytics Code --> <script> //window.resizeTo(1024, 768); //window.resizeTo(800, 600); </script> </body> </html><div class="small" align="center">Page loaded in 0.088 seconds</div>