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> 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 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 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 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? 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{} 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. 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 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. 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{ } 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 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 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... 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 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 Link to comment https://forums.phpfreaks.com/topic/268857-thtd-issues/#findComment-1381462 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.