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 8348335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:39:40+00:00 2026-06-09T07:39:40+00:00

I am developing a wysiwyg page using javascript (no libraries) and because it has

  • 0

I am developing a wysiwyg page using javascript (no libraries) and because it has a fairly specialised application it has to be custom built rather than off-the-peg.

I have, surprisingly, got a long way and it is pretty much complete but I am having some difficulty getting the display right.

I have a div which contains text and images with the images floated right so the text flows around them.

In some places I need the images centred, so I have inserted a div to contain them.

The code bellow illustrates this and it works well.

The problem arises if I have more than one div containing the centred images because the ID of those centreing divs is the same.

If I change the centreing divs to a class the images don’t centre but assume the right float of the parent div.

Is there any way to overcome this?

Is there any real issue having multiple divs with the same id?

I’m not worried about supporting any browsers other than FF.

Any advice would be very greatly appreciated, thanks for reading.

Dim Tim :o)

#details {
    width: 698px;
    background-color: #FFC;
}

#details img {
    float: right;
}   

.centreimage img {
    float: none;
}

.centreimage {
    float: none;
    text-align: center;
}




<div id="details">
  <p>Some text here</p>  
<img src="10750bath.jpg" height="166" width="250"> 
 <p>Which flows around the image on the right</p>
 <p>blah</p>
 <p>blah</p>
 <p>blah</p>
 <p>blah</p>
 <p>blah</p>
 <p>blah</p>

<p>The next image should be centred</p>

<div><img src="10750bath.jpg" width="250" height="166" class="centreimage"></div>

<p>more text</p>
<p>more text</p>
</div>

Thank you all for your help.

Even when I changed the CSS and HTML to be a class the images still failed to centre.

The answer was in the clue from Pekka and specificity was the cause.

The specificity rules give an ID a higher priority than a class.

The “details” div had an ID but the “centreimage” was a class.

I changed the CSS for “details” to a class (& the markup of course) and it now works.

Can’t believe that I spent at least 10 hours trying to sort that out so thanks to everyone for their help.

(Now you know why I am “Dim Tim”) :o)

  • 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-06-09T07:39:41+00:00Added an answer on June 9, 2026 at 7:39 am

    Yes, it’s invalid to have multiple divs with the same id.

    Using a class should work fine:

    div.details {
        width: 698px;
        background-color: #FFC;
    }
    

    If those rules really get overridden, you probably have another rule in place that has higher specificity. In that case, you would have to show us more of your HTML.

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

Sidebar

Related Questions

I am developing a wysiwyg HTML editor using javascript and an editable iframe. Prior
While developing an application using gwt in ecliplse crashed. Now the server is running
Developing a chrome extension using javascript is one of my university projects. I don't
Developing an application using SWT to work in both Linux and Windows. I created
I am developing a WYSIWYG editor using the iframe technique. I need to know
im developing windows application using c#. i want to close the application and show
I'm developing a web application which has the need of a powerful .doc editor.
I have a question about implementing WYSIWYG editors into CakePHP. I'm developing an intranet
Developing a C# .NET 2.0 WinForm Application. Need the application to close and restart
Iam developing one application.In that iam placing the radio buttons(uiimageview) on table view and

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.