Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

CSS Tutorial
CSS Introduction
CSS Basic Syntax
CSS How to Insert
CSS Selector
CSS Internal
CSS External
CSS Inline
CSS Classes
CSS Background
CSS Text
CSS Font
CSS Border
CSS Margin
CSS Padding
CSS List
CSS Dimension
CSS Classification
CSS Positioning
CSS Pseudo-class
CSS Pseudo-element
CSS Media Types
CSS Mouse Cursor
CSS Properties
CSS Layers
CSS Float
CSS Summary

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


CSS Classes
Previous Next

  • You can apply a style to a given class of an element using CSS classes. To do this,you have to declare a style for the class you link the element to the style, then assigning that class to the element.

  • Classes are for you,if you wish to have more than one style of a html tag. Any HTML tag can use these classes.




  • CSS Class Syntax

    By using a dot (.) followed by the class name,you declare a CSS class. You make up the class name yourself. If you want to enter the properties/values to your class ,you can assign it after the class name.

    .class-name { property:value; }

    You can prefix the dot with the HTML element name if you want to use the same class name for multiple elements, but each with a different style.

    html-element-name.class-name { property:value; }

    You could define style sheet classes for each, if you want a purple font paragraph and a blue font paragraph.

    .purple {
    font-family: verdana, arial, helvetica, sans-serif;
    size: 12pt;
    color: #003399;
    }

    .blue {
    font-family: verdana, arial, helvetica, sans-serif;
    size: 12pt;
    color: #663399;
    }

    Then apply this to different paragraphs using following code:

    <p class="purple">The purple paragraph text will go here.</p>

    <p class="blue">The blue paragraph text will go here.</p>
    The <span> tag

    Using the <span> tag, you can also apply this to sections of html like this:

    <p class="purple">This text will be purple until you get to <span class="blue">these words, which are blue</span> and then the text carries on being purple.</p>

    If you wish to display code in a different color depending on its language:

    code.html { color: #4b0082 }
    code.css { color: #191970 }

    For example, using class~="pastoral", we can assign style information to all elements as follows:

    *.pastoral { color: green } /* all elements with class~=pastoral */
    The following assigns style only to H2 elements with class~="pastoral":
    H2.pastoral { color: green } /* H1 elements with class~=pastoral */
    Given these rules, the first H2 instance below would not have green text, while the second would:
    <H2>Not green</H2>
    <H2 class="pastoral">Very green</H2>

    Without an associated element, you can declare classes as follows:

    .note { font-size: small }
    CSS Class Example
    <head>
    <style type="text/css">
    h1.css-section { color:#999999;}
    p.css-section { color:#000099; }
    </style>
    </head>
    <body>
    <h1 class="css-section">CSS Class</h1>
    <p class="css-section">CSS classes can be very useful</p>
    </body>
    O/P:

    CSS Class

    CSS classes can be very useful



    Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
    • blinkbits
    • BlinkList
    • blogmarks
    • co.mments
    • connotea
    • del.icio.us
    • De.lirio.us
    • digg
    • Fark
    • feedmelinks
    • Furl
    • LinkaGoGo
    • Ma.gnolia
    • NewsVine
    • Netvouz
    • RawSugar
    • Reddit
    • scuttle
    • Shadows
    • Simpy
    • Smarking
    • Spurl
    • TailRank
    • Wists
    • YahooMyWeb

    Previous Next

    Keywords: style sheets, css classes html element, cascading style sheets, css classes paragraph


    HTML Quizes
    HTML Quiz
    XHTML Quiz
    CSS Quiz
    TCP/IP Quiz
    XML Quizes
    XML Quiz
    XSL Quiz
    XSLT Quiz
    DTD Quiz
    Schema Quiz
    XForms Quiz
    XSL-FO Quiz
    XML DOM Quiz
    XLink Quiz
    XQuery Quiz
    XPath Quiz
    XPointer Quiz
    RDF Quiz
    SOAP Quiz
    WSDL Quiz
    RSS Quiz
    WAP Quiz
    Web Services Quiz
    Browser Scripting Quizes
    JavaScript Quiz
    VBScript Quiz
    AJAX Quiz
    DHTML Quiz
    HTML DOM Quiz
    WMLScript Quiz
    E4X Quiz
    Server Scripting Quizes
    ASP Quiz
    PHP Quiz
    PERL Quiz
    SQL Quiz
    ADO Quiz
    .NET (dotnet) Quizes
    Microsoft.Net Quiz
    XML Web Services Quiz
    ASP.Net Quiz
    .Net Mobile Quiz
    C# : C Sharp Quiz
    ADO.NET Quiz
    VB.NET Quiz
    Multimedia Quizes
    SVG Quiz
    Flash Quiz
    Media Quiz
    SMIL Quiz
    Web Building  Quizes
    Web Browsers Quiz
    Web Hosting Quiz
    W3C Quiz
    Web Building Quiz
    Web Quality Quiz
    Web Semantic Quiz
    Web Careers Quiz
    Java Quizes
    Java Quiz
    JSP Quiz
    Servlets Quiz
    Struts Quiz
    EJB Quiz
    JMS Quiz
    JMX Quiz
    Programming Langauges Quizes
    C Quiz
    C++ Quiz
    Visual Basic Quiz
    Data Structures Using C Quiz
    Soft Skills Quizes
    Communication Skills Quiz
    Time Management Quiz
    Project Management Quiz
    Team Work Quiz
    Leadership Skills Quiz
    Corporate Communication Quiz
    Negotiation Skills Quiz

    Privacy Policy
    Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.