How to create a different css rule for a second table?¿?¿?

Discussion in 'HTML & Website Design' started by Carl29, Nov 17, 2010.

  1. #1
    Hi,
    I'm having an issue that I don't find the solution.
    I've defined a css rule for the tables on a WP website.
    
    table {
    	border:1px #F6903C solid;
    	margin: 0;
    	padding: 10;
    	border-collapse: collapse;
    	border-spacing: 0;
    }
    
    Code (markup):
    But I've a table that I really don't want to have the border, and even by adding:
    
    <table border="0px" ...
    
    Code (markup):
    or defining a different css rule class
    
    <table class="another_table"...
    
    Code (markup):
    it stills showing the border.

    Any help, please
     
    Carl29, Nov 17, 2010 IP
  2. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #2
    Try this:

    
    .another_table { border: none; }
    
    Code (markup):
    Oh and in straight html... correction to your statement is:
    
    <table border="0">
    
    Code (markup):
    without the px portion.

    Hope that helps,

    Cheers!~
     
    workingsmart, Nov 17, 2010 IP
  3. Carl29

    Carl29 Active Member

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    working, thanks :)
     
    Carl29, Nov 17, 2010 IP
  4. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #4
    Glad it worked out for you.... Cheers!~
     
    workingsmart, Nov 17, 2010 IP
  5. hypokill

    hypokill Well-Known Member

    Messages:
    271
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #5
    I just thought i'd explain alittle more about what workingsmart has suggested. His first suggestion is using a "class"

    CSS Code
    .classname { background:#000; } 
    Code (markup):
    to identify a class for your table

    HTML Tag
    <table class="classname" >
    Code (markup):
    With a class you can use this on as many tags as you like. When i prefer to style only one tag i use an id

    CSS Code
    #idname {background:#FFF;}
    Code (markup):
    HTML Tag
    <table id="idname" >
    Code (markup):
    Hope this helps someone
     
    hypokill, Nov 17, 2010 IP
  6. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #6
    I prefer NO tables at all for layout... ID's only once per page, else w3c invalid
     
    CSM, Nov 17, 2010 IP
    workingsmart likes this.
  7. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #7
    What in the world was the point in doing that?.... The guy had a border issue... What is class/id's going to do?... Should read the OP's post!!

    Cheers!~
     
    workingsmart, Nov 17, 2010 IP
  8. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #8
    Exactly!! But, if the OP has tables, then the OP has tables... Least we can do is help him with what he's got!! :)

    Cheers!~
     
    workingsmart, Nov 17, 2010 IP
  9. Carl29

    Carl29 Active Member

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #9
    I've used "id" . but it's always good lo learn more :)
     
    Carl29, Nov 18, 2010 IP
  10. minusidea

    minusidea Greenhorn

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #10
    #ID should only be used per item... it works great for things like #wrapper #header #logo - things that are not going to change.

    .class should be used for everything else... .padding_left .blue_text .blue_box .clr - you can take and apply multiple classes to an object - <div class="clr blue_box" :)
     
    minusidea, Nov 18, 2010 IP
  11. Carl29

    Carl29 Active Member

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #11
    what do you mean; should I use a class instead of an id for this case. Even if it is a particular table?

     
    Carl29, Nov 18, 2010 IP
  12. hypokill

    hypokill Well-Known Member

    Messages:
    271
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #12
    You might of solved his problem but i hopefully have stopped him from having the same problem again. Helping someone to learn is better then telling someone what to code. Next time think about what your going to type before you type it.
     
    hypokill, Nov 18, 2010 IP
    workingsmart likes this.
  13. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #13
    I thought about what I wrote AS I TYPED IT... :)

    If you want to get technical your explanation was an incorrect assumption anyway... So, if you want I'll gladly spell out how your explanation and or example was only half correct.

    The guy has a tabled area on his site, learning is fantastic and the OP was actually half correct as well, just needed clarification to resolve his problem and LEARN along the way.

    Giving people too much information stemming from a very simple issue can be overwhelming to absorb and may not be taken into context as directed therefore showing him the HALF INCORRECT part of "his own solution" helped him LEARN the other HALF.

    As for YOUR statement of - "When i prefer to style only one tag i use an id" - It isn't a preference, but a proper way to write code.

    I wasn't trying to pick or start an argument with you and nor am I now, was merely pointing out that, although you were doing GOOD by posting, it was a bit more overkill than necessary...

    Cheers!~ Don't worry, go to Happy Hour, have a drink and be Happy!! :)
     
    workingsmart, Nov 18, 2010 IP
  14. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #14
    If you have multiple tables in any area, only 1 should/can have a particular ID the others, if similar should be CLASSES.

    If the tables all have common styles you could just inherit the styles by simply styling the <table> tag like:
    
    table { border: 1px solid #000; }
    
    Code (markup):
    If a particular table is not to have a border, than that table can have a class:
    
    .noborder { border: none; }
    
    Code (markup):
    If you have 1 instance of a particular table, especially if it is a PARENT to a bunch of inner tags, elements, etc than that table should have an ID:
    
    #thistable { border: 3px solid red; }
    
    Code (markup):
    In any case an ID should/can only be used 1x per page. Classes can be used multiple times per page.

    Hope this helps...

    @hypokill = If left something out, please add to it! :) Cheers!~
     
    workingsmart, Nov 18, 2010 IP
  15. hypokill

    hypokill Well-Known Member

    Messages:
    271
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #15
    Really at the end of the day it was just more information for those who read the thread and had the same issues. Also i know it's not a personal preference, read the line again. When I prefer to style one tag i use an id, in other words an id is in order when i decide to style one tag. Either way i was just trying to link the missing dots that this thread hadn't filled in. No harm done

    Edit: Nicely explained, Hopefully this thread can help more people then it is intended to
     
    Last edited: Nov 18, 2010
    hypokill, Nov 18, 2010 IP