Ian Hyzy
Ian Hyzy

Reputation: 522

Changing a span with no attributes with only CSS

I'm trying to write a custom style for a website and am running into a bit of trouble. The following bit of code appears a lot, and I need to remove the float attribute of the span. There are other spans on the page inside <td> elements with floats that must stay untouched, and CSS doesn't have any parent selectors. I can't edit the html in anyway or add any Javascript. What can I do?

<table class="forum_post box vertical_margin" id="post00001">
   <tbody>
     <tr class="colhead-dark">
       <td colspan="2">
         <span style="float: left">
           <a class="post_id" href="stuff.com">text</a>
       </span>
     </td>
   </tbody>
</table>

Upvotes: 3

Views: 453

Answers (1)

zer00ne
zer00ne

Reputation: 43880

.box > tbody > tr > td > span { float: none !important; }

This says:

Find all

  1. spans that are the direct descendant (child) of a...
  2. td which is a child of a...
  3. tr which in turn is a child of...
  4. tbody and finally it being the one and only child of...
  5. table

OR maybe ...

span[style*="float"] { float: none !important; }

This says:

Any span with an attribute of style containing the word float. rel *=[external]

Upvotes: 5

Related Questions