SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this valid? id="domain_categories:2"

    Hi everyone,

    I am refactoring some code for someone and they are dynamically building some content. I noticed they have

    <ul id="domain_categories:2">

    Is that colon ) valid?

    Thanks,
    Bryan

  2. #2
    SitePoint Zealot sularome's Avatar
    Join Date
    Jan 2006
    Location
    Poland
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to specs it's valid:
    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
    http://www.w3.org/TR/html4/types.html#type-name

  3. #3
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll be damned.

    Thanks

  4. #4
    Non-Member
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    4,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    It passes the HTML test
    But not the CSS test

    And Browsers don't swallow it
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>12345 12345 12345 12345 12345</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    	<!-- saved from url=(0022)http://www.domain.com/ -->
    	<style type="text/css">
    	#domain_categories:2{background:#ccccff;}
    	#domain_categories{background:#ccccff;}
    	#domain-categories{background:#ccccff;}
    	</style>
    	<script type="text/javascript">
    
    	</script>
    </head>
    <body>
    
    <ul id="domain_categories:2"><li>12345</li></ul>
    <ul id="domain_categories"><li>12345</li></ul>
    <ul id="domain-categories"><li>12345</li></ul>
    
    </body>
    </html>
    Last edited by all4nerds; Sep 27, 2007 at 07:18.

  5. #5
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I went with underscores anyways thanks for the test though.

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by all4nerds View Post
    Hello

    It passes the HTML test
    But not the CSS test

    And Browsers don't swallow it
    Code:
    ...
    	#domain_categories:2{background:#ccccff;}
    ...
    That's because : is a special character in a selector; it's used for pseudo-classes and pseudo-elements, as in e.g.:
    Code:
    #foo:hover, #foo::after {...}
    You need to escape it:
    Code:
    #domain_categories\:2 {...}
    Simon Pieters

  7. #7
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is valid in HTML for IDs to contain colon, however in namespace-aware XML it is not:
    Quote Originally Posted by Namespaces in XML
    It follows that in a namespace-valid document:
    • No attributes with a declared type of ID, IDREF(S), ENTITY(IES), or NOTATION contain any colons.
    -- http://www.w3.org/TR/REC-xml-names/#Conformance
    Simon Pieters


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •