Skip to main content
the_marketing_guy
Participant
February 15, 2019
Answered

Multiple Divs, same name on page?

  • February 15, 2019
  • 2 replies
  • 393 views

I have a page of photos with accompanying text on a page. The photo-text divs are all class formatted (div class="format_name"), and they are all the same, CSS-wise, and are arranged vertically on the page.  Originally, when there were just three sets of photo-text, I created new divs for each one. Now I need to add 4 more sets, so I just pasted the first three, and repasted the first one over again, to get 7. It's a fluid layout; I have checked the corresponding CSS files (three of them) for each screen view, and those files are all the same within each view.

I have tested this new page on a few different browsers, and it seems to work. And the more I think about it, I probably only needed 1 pair of photo-rext Divs, which I could then copy and paste 6 times. They would all have the same name (and the same corresponding CSS file), but other than their sequence on the page (in the source code), there is no difference in their formatting attributes (width, margin, etc.)

This approach would seem to economize the css file by avoiding redundant formatting instructions. On the other hand, I don't do this enough to get good at it. My question: Is there any reason here not to use multiple Divs with the same name on a page? (Dreamweaver CS6)

Thanks

    This topic has been closed for replies.
    Correct answer Nancy OShea

    https://forums.adobe.com/people/the+marketing+guy  wrote

    My question: Is there any reason here not to use multiple Divs with the same name on a page? (Dreamweaver CS6)

    No.   But  HTML selectors are reusable.  So you could style the relevant HTML selectors and skip the classes.

    section {   }

    section h3 {   }

    section img {    }

    section p {   }

    <section>

    <h3>Heading</h3>

    <img src="image_name.jpg">

    <p>Some description here...</p>

    <section>

    2 replies

    Nancy OShea
    Community Expert
    Nancy OSheaCommunity ExpertCorrect answer
    Community Expert
    February 15, 2019

    https://forums.adobe.com/people/the+marketing+guy  wrote

    My question: Is there any reason here not to use multiple Divs with the same name on a page? (Dreamweaver CS6)

    No.   But  HTML selectors are reusable.  So you could style the relevant HTML selectors and skip the classes.

    section {   }

    section h3 {   }

    section img {    }

    section p {   }

    <section>

    <h3>Heading</h3>

    <img src="image_name.jpg">

    <p>Some description here...</p>

    <section>

    Nancy O'Shea— Product User & Community Expert
    Legend
    February 15, 2019

    https://forums.adobe.com/people/the+marketing+guy  wrote

    My question: Is there any reason here not to use multiple Divs with the same name on a page? (Dreamweaver CS6)

    You can apply the same  'class' name to as many divs or containers or elements etc on a page as you want.

    The rule for an 'id' is that you should only apply that once per page, to a div or container or element.