Skip navigation
mktgdave91
Currently Being Moderated

Snippets Problem: HTML ID changes when pasted twice or more

Sep 6, 2012 1:49 PM

Tags: #dreamweaver #snippets #html_code

Hi there,

 

I have an external CSS style sheet in a website that formats elements in a snippet. However, when I paste a snippet more than once, the ID field receives a number. For example, the first snippet will post with an element as <td id="Title">, while the second paste will cause it to be <td id="Title2">. The CSS sheet only knows to format elements with the ID "Title" so when I paste this more than once the ID changes.

 

Under normal circumstances, I would just edit the HTML code, however, the site is meant to be heavily template driven, and the second person managing it doesn't have time to edit/learn HTML code as they are busy with other tasks. For the moment, PHP/MySQL isn't an option either.

 

Is there a way to have pasted elements not include an additional number in the ID fields?

 

Thanks,

David

 
Replies
  • Currently Being Moderated
    Sep 6, 2012 2:04 PM   in reply to mktgdave91

    You can't technically use the same HTML id twice.

     

    <div id="edgar"></div>

    <div id="edgar"></div>

     

    Is a no-no.

     

    Use classes instead...

     

    <div class="edgar"></div>

    <div class="edgar"></div>

     

    Your css would go from

     

    #edgar {

         some attributes

    }

     

    to

     

    .edgar {

         some attributes

    }

     

    EDIT: Or in your case <td id="Title"> to <td class="Title"> and in the CSS #Title to .Title

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points