Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 378577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:48:29+00:00 2026-05-12T14:48:29+00:00

Is it OK to use hyphen – in an XML element name? e.g. <rank-type>Rank</rank-type>

  • 0

Is it OK to use hyphen - in an XML element name?

e.g.

<rank-type>Rank</rank-type>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:48:29+00:00Added an answer on May 12, 2026 at 2:48 pm

    As readily stated by Vinko and hacker, the answer is

    Yes, dashes are allowed in names, whether for element names or attribute names. However a dash cannot be the first character in the name.

    The W3C standard defines names as follows (section 2.3)

    NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
    NameChar  ::=   NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
    Name  ::= NameStartChar (NameChar)*
    

    Ignoring the various extended ASCII charactes and double-byte characters (which starting with # sign in the syntax definition), a name needs to start with an upper or lower case letter (A-Z), a colon (:) or an underscore. The characters following this start character, if any, i.e. if the name is not a single character, can be any of the valid start characters and/or any of the digits (0-9), the famous dash (-) and the dot (.)

    As pointed out in the other responses, where possible, it is advisable to avoid certain characters, even though they may be legal, lest we risk encountering some implementation specific difficulties with various parsers and interop layers.

    The W3C itself has implicitly vindicated the use of dashes as these are extensively used in XSL for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I make in MediaWiki links lowercase and use hyphen instead of underscore as
I'm playing around with Lucene and noticed that the use of a hyphen (e.g.
use the [] symbol in the name of the form field you are submitting
I'd like my console app to use hyphen-named inputs, like so: myApp -S myServerName
I made a very basic example, and when I use a hyphen on the
How is it possible to use hyphen in resources urls? For example: /my-model/ or
Trying to use jquery to output a string that contains a hyphen like so:
I'm trying to rename a database to a name with a hyphen (-). ALTER
Use Case Show a photo uploaded by the user in a square box with
use C#,want to upload excel file on google doc. bellow syntax use to upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.