www.webdeveloper.com
Results 1 to 5 of 5

Thread: Discuss: what can you do in the case?

  1. #1
    Join Date
    Apr 2005
    Posts
    210

    Discuss: what can you do in the case?

    I find <form> has a property called 'id', i.e. 'product'.

    If the <form> also has an ID in css, i.e.
    Code:
    #myform {
    ....
    }
    The <form> will be:
    Code:
    <form id="product" id="myform" .... 
    </form>
    I guess code above doesn't work (never test).

    What can you do in the case?

    Is it only solution to change ID #myform to class .myform?
    What else you can do?

    I believe this is important reason that people prefer class in css, do you think so?


    .

  2. #2
    Join Date
    Mar 2011
    Posts
    1,138
    There's nothing wrong with the CSS and HTML code you posted. The stylesheet should control the appearance of the form #myform. If it doesn't, the problem lies elsewhere. Post the code or the URL of the page so someone can look at it and help you.
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    There is something very much wrong with the HTML. As you observed, elements can only have one ID attribute and ID attributes need to be unique on a page. But you can run classes together and use them multiple times on a page. SO you could use
    Code:
    <form action="Some_Script.php" id="product" class="myform">
    or even
    Code:
    <form action="Some_Script.php" class="product myform">
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  4. #4
    Join Date
    Nov 2002
    Posts
    2,632
    It's bad naming if you come away with two IDs. I would simply call it product or product_form.

  5. #5
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Or:
    Code:
    #myform, #product {
    ....
    }
    ...
    <form id="product">
    An HTML element can not have the same attribute twice (or more), thus it can not bear two id tokens.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles