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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:50:21+00:00 2026-06-03T04:50:21+00:00

I have some html in this format: <ul id=foo> <li class=bar><a href=#>Reports</a> <span> <a

  • 0

I have some html in this format:

<ul id="foo">
    <li class="bar"><a href="#">Reports</a>
      <span>
        <a href="#" class="fooLink">First Report</a>
        <a href="#" class="fooLink">Second Report</a>
     </span>
  </li>
</ul>

Essentially, I want the ‘reports’ link in the menu to expand when clicked, and display the links below it, padded to the side, so it looks like this:

Reports
   First report
   Second report

This is my css code:

.fooLink
{
    padding-left: 20%; 
    padding-top: 0px;
    display:block;
}

However this doesn’t work. If I examine the links in firebug, I see that the display:block; line is blocked. However if I do this:

<a href="#" 
   style="padding-left:20%; padding-top:0px; display:block;">Second Report</a>

Then it works as I want it. Why doesn’t it work if i put it in the css class?

  • 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-03T04:50:23+00:00Added an answer on June 3, 2026 at 4:50 am

    Applying CSS via the style attribute always* trumps styles provided via stylesheets, due to specificity, as @Kirean mentions.

    That means that when you move your CSS to an external stylesheet, it has to compete with other defined styles.

    You can make your style selector more specific than the other definition, but you have to know what you are competing with.

    .fooLink is more specific than a

    a.fooLink is more specific than .fooLink

    span a.fooLink is more specific still, etc, etc

    According to the W3C specification, your .fooLink selector can be trumped by any selector with: more class selectors (.foo .fooLink), the same number of class selectors and more type selectors (.foo a), or any selector with an ID (#foo *), assuming the selector applies to the same element.

    Now, the caveat (as implied by the asterisk above) is that you can override this behavior using !important. !important trumps other defined style attributes. If there are multiple !important declarations, they are resolved according to standard specificity rules.

    So, the best solution is to make your style as specific as possible, and edit other styles which may be conflicting.

    If, however, those other definitions are out of your control (site-wide CSS stylesheets or something like that), use !important:

    .fooLink
    {
        padding-left: 20%; 
        padding-top: 0px;
        display:block !important;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML that looks like this: <div> <div class=value> <a href=# class=clicker>Some
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have some HTML like this: <div id=MyDiv> <div class=Class1> <div class=SClass1></div> </div> <div
I have some HTML like this: <input type=radio class=MyRadio name=TheName> <label for=TheLabel>the text</label> How
I have some HTML that looks like this: <div class=product> Content In Here <div
I have some html snippet <div id=title>This is title<span id=close>X<span><div> The width of this
I have some code like this: respond_to do |format| format.html { @all_activities = current_user.recent_activities(@size_per_page,params[:start],nil)
I have a long list of HTML in this format: <div id=item555> Some name
I have a problem where I have some html like this <p>There is the
I'm experimenting playing video in a UIWebView. If I have some html like this:

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.