taith Posted September 27, 2012 Share Posted September 27, 2012 hello, im looking to add some automation to my css... what im looking for, eventually, is for it to automatically detect when theres a th tag, and select the tds thereafter... however, for some reason, its not even detecting the tables with th's... what am i doing wrong? <!DOCTYPE html> <html> <head> <style type="text/css"> table~th{ background:red; } </style> </head> <body> <table> <tr> <th>test</th> </tr> <tr> <td>test2</td> <tr> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/ Share on other sites More sharing options...
taith Posted September 27, 2012 Author Share Posted September 27, 2012 im pretty sure i have it backwards somewhere... i need to select the tables with the th children, not selecting the th itself Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381405 Share on other sites More sharing options...
taith Posted September 27, 2012 Author Share Posted September 27, 2012 E>F - Matches any F element that is a child of an element E. i need one that goes the other way, that matches any E element that has an F child Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381406 Share on other sites More sharing options...
Jessica Posted September 27, 2012 Share Posted September 27, 2012 (edited) table th td{ style here } However, if your HTML is valid, EVERY td will be a child of a TH. That's the same as just doing td{} I meant tr, not th. What are you actually trying to do? Edited September 27, 2012 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381407 Share on other sites More sharing options...
taith Posted September 27, 2012 Author Share Posted September 27, 2012 that would select all tables, or if with a class/id modifier... im looking for a way of css automatically detecting if theres a th child... essentially id expect it to look like this... table<th td{} Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381409 Share on other sites More sharing options...
Jessica Posted September 27, 2012 Share Posted September 27, 2012 No, it won't. It will select all tds within a th within a table. (Which is invalid, I thought you were talking tr, not th.) What are you REALLY TRYING TO DO? all th within a table is: table th{} That's it. Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381410 Share on other sites More sharing options...
taith Posted September 27, 2012 Author Share Posted September 27, 2012 i dont want it to select the th tho... i want it to select the tds, but ONLY IF there is a th in the table... something tells me css cannot do this Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381412 Share on other sites More sharing options...
Jessica Posted September 27, 2012 Share Posted September 27, 2012 Okay, I don't believe CSS can do that. I understand what you mean now though, let me think/look around. Maybe someone else will know too. Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381414 Share on other sites More sharing options...
Jessica Posted September 27, 2012 Share Posted September 27, 2012 Try this? tr>th ~ tr>td{ } Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381417 Share on other sites More sharing options...
taith Posted September 27, 2012 Author Share Posted September 27, 2012 Try this? tr>th ~ tr>td{ } nothing Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381420 Share on other sites More sharing options...
Mahngiel Posted September 27, 2012 Share Posted September 27, 2012 this is why classes exist, and why an element can have multiple classes Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381443 Share on other sites More sharing options...
taith Posted September 27, 2012 Author Share Posted September 27, 2012 yes, im aware of using classes, i was hoping that it would be doable without... Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381451 Share on other sites More sharing options...
Mahngiel Posted September 28, 2012 Share Posted September 28, 2012 (edited) yes, im aware of using classes, i was hoping that it would be doable without... That's fine, but it's obviously causing more strain to figure this out than throw a class at it where you can guarantee the results. Path of least resistence is preferred IMO Edited September 28, 2012 by Mahngiel Quote Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.