Introduction To Cascading Style Sheets

Feb 15 22:00 2002 Mitchell Harper Print This Article

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,Guest Posting
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

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 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>-<br>-<br>-<br>-</p> <p>Source: <a href="">Free Guest Posting Articles</a> from</p> <div class="panel-tags-cats"> <span><i class="fa fa-tag"></i>  Article "tagged" as:</span> <div class="tagcloud"> <a href="/tag/cascading-style.html">cascading style</a> <a href="/tag/big-h1-tag.html">big h1 tag</a> <a href="/tag/separate-html.html">separate html</a> <a href="/tag/rulesand-styles.html">rulesand styles</a> <a href="/tag/html-document.html">html document</a> </div> <div class="article-splitter"></div> <span><i class="fa fa-folder-open"></i>  Categories:</span> <div class="category-cloud"> <a href="/articles/css.html">CSS</a> </div> </div> </div> <!-- END .def-panel --> </div> <!-- BEGIN .def-panel --> <div class="def-panel"> <div class="panel-title"> <h2>About Article Author</h2> </div> <div class="about-author"> <span class="about-author-header"> <img width="100" alt="Mitchell Harper" src="/images/no-avatar.png" /> </span> <div class="about-author-content"> <!--% <div class="right"> <a href="#" class="soc-facebook"><i class="fa fa-facebook"></i></a> <a href="#" class="soc-twitter"><i class="fa fa-twitter"></i></a> <a href="#" class="soc-pinterest"><i class="fa fa-pinterest"></i></a> <a href="#" class="soc-google-plus"><i class="fa fa-google-plus"></i></a> <a href="#" class="soc-linkedin"><i class="fa fa-linkedin"></i></a> </div> %--> <strong>Mitchell Harper</strong> <p>Mitchell is the founder and senior editor of<br> 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:<br></p> <a href="/author/Mitchell+Harper.html" class="read-more-link">View More Articles<i class="fa fa-chevron-right"></i></a> </div> </div> <!-- END .def-panel --> </div> <!-- BEGIN .def-panel --> <div class="def-panel"> <div class="panel-title"> <h2>Also From This Author</h2> </div> <div class="related-articles"> <div class="item"> <!-- BEGIN fragments/homepage/articles/one :: xlarge --> <div class="item-header"> <a href="/articles/webmasters/three-ways-to-add-versatile-content-to-your-site-or-ezine.html" class="hover-image"><img src="/images/default/small/default-0.jpg" alt="" /></a> </div> <div class="item-content"> <h4><a href="/articles/webmasters/three-ways-to-add-versatile-content-to-your-site-or-ezine.html">Three Ways to Add Versatile Content to Your Site or eZine</a></h4> </div> <!-- END fragments/homepage/articles/one :: xlarge --> </div> <div class="item"> <!-- BEGIN fragments/homepage/articles/one :: xlarge --> <div class="item-header"> <a href="/articles/newsletters/creating-the-perfect-newsletter.html" class="hover-image"><img src="/images/default/small/default-1.jpg" alt="" /></a> </div> <div class="item-content"> <h4><a href="/articles/newsletters/creating-the-perfect-newsletter.html">Creating The Perfect Newsletter</a></h4> </div> <!-- END fragments/homepage/articles/one :: xlarge --> </div> <div class="item"> <!-- BEGIN fragments/homepage/articles/one :: xlarge --> <div class="item-header"> <a href="/articles/javascript/some-useful-javascript-tricks.html" class="hover-image"><img src="/images/default/small/default-2.jpg" alt="" /></a> </div> <div class="item-content"> <h4><a href="/articles/javascript/some-useful-javascript-tricks.html">Some Useful JavaScript Tricks</a></h4> </div> <!-- END fragments/homepage/articles/one :: xlarge --> </div> </div> <!-- END .def-panel --> </div> <!-- BEGIN .def-panel --> <div class="def-panel"> </div> <!-- BEGIN .def-panel --> <div class="def-panel"> </div> <!-- END .main-content-spacy --> </div> <aside class="small-sidebar"> <!-- BEGIN fragments/article/small-sidebar :: small-sidebar --> <!-- BEGIN .widget --> <div class="widget"> <h3>Related Articles</h3> <div class="large-article-list"> <a href="/articles/css.html" class="more-articles-button">show all articles</a> </div> <!-- END .widget --> </div> <!-- BEGIN .widget --> <div class="widget"> <div class="banner"> <script async src="" crossorigin="anonymous"></script> <!-- 160x600 --> <ins class="adsbygoogle" style="display:inline-block;width:160px;height:600px" data-ad-client="ca-pub-7277013290225659" data-ad-slot="8249883319"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <!-- END .widget --> </div> <!-- BEGIN .widget --> <div class="widget"> <h3 style="border-bottom: 2px solid #0b71a1; color: #0b71a1;">Top In Category</h3> <div class="large-article-list"> <a href="/articles/css.html" class="more-articles-button">Read more</a> </div> <!-- END .widget --> </div> <!-- END fragments/article/small-sidebar :: small-sidebar --> </aside> <aside id="sidebar"> <!-- BEGIN .widget --> <div class="widget"> <!-- END .widget --> </div> <!-- BEGIN .widget --> <div class="widget"> <h3>Popular Free Articles</h3> <div class="small-article-list"> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/finance/does-your-life-include-a-ripe-planplanning-tips-for-retirement-investing-protection-and-estate-planning-part-2-investing.html">Does Your Life Include a RIPE Plan?—Planning Tips for Retirement, Investing, Protection, and Estate Planning – Part 2 (Investing)</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/business/8-tactics-to-develop-a-powerful-marketing-strategy.html">8 Tactics To Develop A Powerful Marketing Strategy</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/technology/benefits-of-online-backup.html">Benefits of Online Backup</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/technology/lg-solar-panels-vs-q-cells-which-panels-are-best-for-you.html">LG Solar Panels vs Q CELLS: Which Panels Are Best for You?</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/sports/watch-the-big-game-icc-world-cup-2022-on-yupptv.html">Watch the big game ICC World Cup 2022 on YuppTV</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/family/1-simple-technique-to-stop-snoring-eft.html">1 Simple Technique To Stop Snoring - EFT</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/business/ten-tips-for-cross-cultural-communication.html">Ten Tips for Cross Cultural Communication</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/home-repair/overview-report-about-interior-furniture-market-of-vietnam-2015-2020.html">Overview report about Interior Furniture Market of Vietnam (2015-2020)</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/computers/most-frequently-used-devops-tools-in-2020.html">Most Frequently Used DevOps Tools in 2020</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> <div class="item no-image"> <!-- BEGIN fragments/homepage/articles/one :: noimg --> <div class="item-content"> <h4> <a href="/articles/health/4-good-habits-for-healthy-people.html">4 Good Habits For Healthy People</a> </h4> </div> <!-- END fragments/homepage/articles/one :: noimg --> </div> </div> <!-- END .widget --> </div> <!-- BEGIN .widget --> <div class="widget"> </div> <!-- BEGIN .widget --> <div class="widget"> <h3>Categories Cloud</h3> <div class="tagcloud"> <a href="/articles/politics.html">Politics</a> <a href="/articles/metaphysical.html">Metaphysical</a> <a href="/articles/marriage.html">Marriage</a> <a href="/articles/psychology.html">Psychology</a> <a href="/articles/fitness.html">Fitness</a> <a href="/articles/gardening.html">Gardening</a> </div> <!-- END .widget --> </div> </aside> </div> </div> </section> <!-- BEGIN .footer --> <footer class="footer"> <!-- BEGIN .footer-widgets --> <div class="footer-widgets"> <!-- BEGIN .wrapper --> <div class="wrapper"> <div class="widget"> <h3>Contact Information</h3> <div class="contact-widget"> <div class="large-icon"> <i class="fa fa-phone"></i> <span>+1 628 987 2271</span> </div> <div class="large-icon"> <i class="fa fa-envelope"></i> <span><a href=""></a></span> </div> <p>Articles Factory allows writers and marketers to submit copyright free articles on a mixture of topics which can be distributed with no charge on websites, blogs, and print newsletters.</p> <p><strong>Author's statement of copyright, signature, any hyperlinks inside of article remain intact.</strong></p> </div> </div> <div class="widget"> <h3>Copyright Free Articles</h3> <div class="small-article-list"> <div class="item"> <div class="item"> <!-- BEGIN fragments/homepage/articles/one :: small --> <div class="item-header"> <a href="/articles/web-design/small-business-website-with-wordpress-seo-friendly-mobile-responsive-website.html" class="hover-image"><img src="/images/default/small/default-0.jpg" alt="" /></a> </div> <div class="item-content"> <h4><a href="/articles/web-design/small-business-website-with-wordpress-seo-friendly-mobile-responsive-website.html">Small Business Website with WordPress, SEO Friendly Mobile Responsive Website</a></h4> </div> <!-- END fragments/homepage/articles/one :: small --> </div> </div> <div class="item"> <div class="item"> <!-- BEGIN fragments/homepage/articles/one :: small --> <div class="item-header"> <a href="/articles/business/amrapali-dream-valley-villas-make-your-dream-come-true.html" class="hover-image"><img src="/images/default/small/default-1.jpg" alt="" /></a> </div> <div class="item-content"> <h4><a href="/articles/business/amrapali-dream-valley-villas-make-your-dream-come-true.html">Amrapali Dream Valley Villas: Make Your Dream Come True</a></h4> </div> <!-- END fragments/homepage/articles/one :: small --> </div> </div> <div class="item"> <div class="item"> <!-- BEGIN fragments/homepage/articles/one :: small --> <div class="item-header"> <a href="/articles/business/what-is-the-importance-of-a-customs-broker.html" class="hover-image"><img src="/images/default/small/default-2.jpg" alt="" /></a> </div> <div class="item-content"> <h4><a href="/articles/business/what-is-the-importance-of-a-customs-broker.html">What is the Importance of a Customs Broker?</a></h4> </div> <!-- END fragments/homepage/articles/one :: small --> </div> </div> </div> </div> <div class="widget"> <h3>Resources</h3> <div class="subscribe-widget"> <div class="item-content"> <div><a href="/my" class="read-more-link" rel="nofollow" style="margin-bottom:5px">My Account</a></div> <div><a href="/all-categories.html" class="read-more-link" style="margin-bottom:5px">Browse Categories</a></div> <div><a href="/archive.html" class="read-more-link" style="margin-bottom:5px">Archive</a></div> <div><a href="/contact.html" class="read-more-link" rel="nofollow" style="margin-bottom:5px">Contact Us</a></div> </div> </div> </div> <div class="clear-float"></div> <!-- END .wrapper --> </div> <!-- END .footer-widgets --> </div> <!-- BEGIN .wrapper --> <div class="wrapper"> <ul class="right"> <li><a href="/terms.html" rel="nofollow">Terms of Use</a></li> <li><a href="/privacy.html" rel="nofollow">Privacy Policy</a></li> </ul> <p>© 2022 Copyright <strong>Articles Factory</strong>. All Rights reserved.</p> <!-- END .wrapper --> </div> <!-- END .footer --> </footer> <!-- END .boxed --> </div> <!-- Scripts --> <script type="text/javascript" src="/jscript/jquery-latest.min.js"></script> <script type="text/javascript" src="/jscript/modernizr.custom.50878.js"></script> <script type="text/javascript" src="/jscript/iscroll.js"></script> <script type="text/javascript" src="/jscript/dat-menu.js"></script> <!--[if lte IE 9]> <script type="text/javascript" src="/jscript/ie-fix.js"></script> <![endif]--> <script type="text/javascript" src="/jscript/theme-scripts.js"></script> <script type="text/javascript" src="/jscript/lightbox.js"></script> <script type="text/javascript" src="/jscript/owl.carousel.min.js"></script> <script> jQuery(document).ready(function() { jQuery(".related-articles").owlCarousel({ items : 3, autoplay : false, nav : false, lazyload : false, dots : false, margin : 30, responsive:{ 0:{ items: 1 }, 400:{ items: 2 }, 700:{ items: 3 } } }); }); </script> <script type="text/javascript" src="/jscript/jquery.countdown.min.js"></script> <script type="text/javascript" src="/jscript/moment.js"></script> <script type="text/javascript" src="/jscript/moment-timezone-with-data.js"></script> <!-- 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=""></script> <noscript><img src="" alt="free web stats" border="0"></noscript> <!-- End of StatCounter Code --> <!-- Start of Google Analytics Code --> <script src="" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-88528-1"; urchinTracker(); </script> <!-- End of Google Analytics Code --> </body> </html>