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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:36:32+00:00 2026-05-26T15:36:32+00:00

In my HTML there are a lot of elements. Some div elements have an

  • 0

In my HTML there are a lot of elements. Some div elements have an table as child element. I want to set some css properties to all div element, but differs between those with table and those without it.

My first approach:

The class property of those div-elements containing a table is set to something with ‘table’, so I can select them with attribute selectors as described here: http://www.w3.org/TR/selectors/#attribute-selectors

div[class*="Table"]
{ 
/* Set Properties for all div with 'table' inside class-attribute */
}

Unfortunately there seems to be no opposite attribute selectors.

So my first question is: Is that right or what can I do?

My next approach is, to check if one child is a table. With help of google I only find how to select e.g. first-child of an element, but not how to check, if it is a table or not.

So my question 2 and 3 is: How do I select those div elements, containing (or not containing) a table as child?

Edit: Usually the table would be first-child, but if possible I would like to check all child elements being a table or not

  • 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-05-26T15:36:32+00:00Added an answer on May 26, 2026 at 3:36 pm

    Your approach of adding a class to <div>s that contain a table is the only way to do this with CSS.

    There is the :not() selector if that helps with this approach. It’s unsupported by IE 8 and below and Opera 9 and below, but all other browsers support it.

    You can get the same effect by setting styles for <div>s that don’t contain tables with the div selector, then overriding those styles for <div>s with the table class, but :not() might make it less verbose. Demo here: http://jsfiddle.net/LyLS5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say I have some html document with a lot of text. Is it
I have a list of html elements that have some text. I need to
I would like my tinymce editor to allow all the html elements, include some
I have some existing code. This code uses an html table for a banner.
I have 2 directories each with a .htaccess file: html/.htaccess - There is a
Are there any html helpers for page navigation. eg. if i have 1000 records
Are there any html/css checkers that are javascript based like JSLINT?
I would like to write a CSS selector rule that selects all elements that
Of course, we have been witnessing a lot of browsers differences in rendering elements,
I have an application that does a lot of resizing elements to ensure they

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.