Style Sheets
  Home arrow Style Sheets arrow Page 4 - Learn CSS, Selectors, part 2
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Learn CSS, Selectors, part 2
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 14
    2005-06-13

    Table of Contents:
  • Learn CSS, Selectors, part 2
  • The Attribute Selector
  • Specific-Value Attribute Selector
  • The Specific-Values Attribute Selector
  • The Begin With Specific-Value Attribute Selector
  • The End With Specific-Value Attribute Selector
  • The Contain-Value Attribute Selector

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Learn CSS, Selectors, part 2 - The Specific-Values Attribute Selector


    (Page 4 of 7 )

    The specific-values attribute selector is very similar to the specific-value attribute selector. Instead of matching only one value for the element's attribute, this selector matches one of the multiple space separated values like the following:

    a[href~="http://www.w3.org" "http://www.w3.org/TR/CSS21"]
    {
    background-color: black;
    color: white;
    text-decoration: none;
    font-size: 1.1em;
    font-family: Tahoma;
    }

    Note the use of the tilde symbol with the equal sign, and the space between the two string values. This selector states that any anchor element that has the href attribute value set to http://www.w3.org or http://www.w3.org/TR/CSS21 will have the above styling rule. Unfortunately, there is no browser support for this selector yet.

    The lang value Attribute Selector

    Actually, this attribute has been defined for certain behavior. The selector applies the rule if the value of the attribute matches the specified value, or the specified value with added "-". Let's look at an example. Modify the CSS file to look like this:

    a[href~="http://www.w3.org"]
    {
    background-color: black;
    color: white;
    text-decoration: none;
    font-size: 1.1em;
    font-family: Tahoma;
    }
    p[lang|="en"]
    {
    color: blue;
    }
     

    Now modify the first <p> element in the HTML to look like this (just add the lang attribute and set the value to "en-us"):

    <p lang="en-us">You can use CSS with markup languages like HTML, XHTML and XML. All
    those markup languages and also CSS has Specifications as the <a
    href="http://www.w3.org">W3C website</a>
    </p>

    The selector states that any <p> element that has the attribute lang, that has the value that begins with "en" or "en-" will have blue text. This selector applies the formatting rule if a match of the specified value has been found, or a match of the value plus the "-" symbol like "en" or "en-" has been found. 

    More Style Sheets Articles
    More By Michael Youssef


     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek