CoderTools Web site

HTML Style Tag

Adding Cascading Style Sheets to Your HTML Pages


Cascading Style Sheets or C.S.S. have been around for a while now and are very important to web development. In the past you could get by with learning HTML but now with modern standards such as XHTML many of the formatting attributes and tags in HTML have been deprecated in favour of CSS commands.
This is a good thing but it does mean there is more to learn now to be effective at creating web pages.
The style tag is one method that allows you to incorporate stylesheets into your web pages.

Examples for <style>

The style tag is generally only used in the head tag. Some browsers support putting style tags within the body tag but this is not recommended.
    <html>
    <head>
        <style type="text/css">
            #heading1 { background:red; }
        </style>
    </head>
    <body>
        <h1 id="heading1">This is a heading tag
            with red background using stylesheets</h1>
    </body>
    </html>Give it a go!

Attributes for <style>


Name Values Description
type content type e.g. text/css Stylesheet language. The only current value is text/css
media all
aural
braille
handheld
print
projection
screen
tty
tv
The destination for the style information. The default is screen. Can combine values using comma separated list.
Not generally used in web pages.
title text The title of the stylesheet.

3/27/2017 4:28:09 PM
Terms Of Use | Privacy Statement | Copyright 2006-2015 © Independence Software LLP