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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:16:41+00:00 2026-06-18T00:16:41+00:00

I’m trying to tidy up my html, css and javascript. I know that it

  • 0

I’m trying to tidy up my html, css and javascript. I know that it is sloppy, but I can’t fathom a cleaner way to write things. I can see hat there must be tidier ways though.

http://jsfiddle.net/craigzilla/hk8SR/

Any suggestions?

#btn1 {
height: 88px;
width: 110px;
float: left;
position: absolute;
}
#btn2 {
height: 88px;
width: 110px;
float: left;
position: absolute;
left: 110px;
}
#btn3 {
height: 88px;
width: 110px;
float: left;
position: absolute;
left: 220px;
}
.rollover1 {
background-image: url(http://www.placehold.it/110x88);
height: 88px;
width: 110px;
opacity: 0;
float: left;
}
.rollover2 {
background-image: url(http://www.placehold.it/110x88);
height: 88px;
width: 110px;
opacity: 0;
float: left;
}
.rollover3 {
background-image: url(http://www.placehold.it/110x88);
height: 88px;
width: 110px;
opacity: 0;
float: left;
}
  • 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-18T00:16:42+00:00Added an answer on June 18, 2026 at 12:16 am

    Well first of all, you can assign multiple selectors the same rule. Something like this:

    .rollover1, .rollover2, .rollover3 {
        background-image: url(http://www.placehold.it/110x88);
        height: 88px;
        width: 110px;
        opacity: 0;
        float: left;
    }
    

    Even better than that, though, you could eliminate the need for .rollover1, 2, and three and just make a .rollover class that you apply to everything.

    If you need a different image for each rollover, then this would work:

    .rollover1, .rollover2, .rollover3 {
        height: 88px;
        width: 110px;
        opacity: 0;
        float: left;
    }
    .rollover1{
        background-image: url(http://www.placehold.it/110x88);
    }
    .rollover2{
        background-image: url(http://www.placehold.it/110x88?2);
     }
    

    You can do the same with your IDs.

    If you’re seriously looking to clean up your styles, look in to “object oriented CSS” (Note: I think the name “OOCSS” is HIGHLY misleading, but it is still good practice). Object Oriented CSS, basically changes the approach to writing CSS. Rather than saying “this CSS is for my button that is blue and has a margin of 5px” and outputting code like this:

    #myBlueButton{
        background-color:#00f;
        margin:5px;
    }
    
    <button id="myBlueButton">
    

    You write CSS like this:

    .blue{
        background-color:#00f;
    }
    .margin5px{
        margin:5px;
    }
    

    And then your button will look like this:

    <button class="blue margin5px">
    

    This encourages seperation of concerns and symantic classes, while reducing your need for IDs and reducing the need for overly specific CSS selectors. It also allows you to easily re-use your CSS styles without having to repeat yourself.

    Even better than OOCSS, though, look in to things like SASS and LESS Which allow you to write rules that will generate your CSS for you.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string

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.