0

I have some custom CSS for a table that needs to only change this specific table and leave the rest of the page to followed the regular template.css. I'm not sure where to put this to it works with Joomla and isn't accessed by the rest of the Joomla website.

Let's say the CSS code looks something like this, just as an example:

<style>
body {
line-height: 1.5;
}
table {
border: 1px solid #ccc;
}
table tr {
background: #ffffff;
}
@media screen and (max-width: 600px) {
  table {
    border: 0;
  }
  table caption {
    font-size: 1.3em;
  }
}
</style>

Where do I put the above CSS style in Joomla to only be used on that specific page and only for that one table?

Where do I place this CSS code? Do I create a flexicode module and put the CSS in there to only appear on this page? Add it to the custom.css? How can only body and table be assigned to that specific table to there are no conflicts with the body and perhaps table that might already exist in the template.css and possibly elsewhere?

1 Answer 1

2

If you just mean a table in a standard Joomla article (as opposed to a module), then I'd personally just add a class to the table, and then reference the table by that class in the custom css.

ie change <table> to <table class="green"> and reference it with table.green {}

To add the class, you are probably better going in the html view and doing it manually to make sure it appears in the right place, though you could also add the style to the editor.css and do it via the WYSIWYG (anything in your template's editor.css file appears in the styles dropdown).

2
  • Thanks. What about the @media screen and (max-width: 600px)? How is that contained to this class? Commented Jan 20, 2018 at 19:09
  • 1
    If everything within the media query only refers to the new class (table.green or whatever), then it won't impact on anything else.
    – RichardB
    Commented Jan 20, 2018 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.