Hello everyone,
can you help me with applying CSS to tables? I'm trying to change cell padding for a particular table style, adding the style code to custom.css file in the skin. However, the cells have inline style code (settings from the style defined in the project), which overrides the CSS. Can I remove the padding from the style in project? How is the table to be CSS-styled if inline styles always have priority?
Tables and CSS
Moderators: Alexander Halser, Tim Green
-
- Posts: 53
- Joined: Thu Sep 24, 2015 11:57 am
- Location: Moscow
Tables and CSS
Omit needles swords
- Martin Wynne
- Posts: 2656
- Joined: Mon May 12, 2003 3:21 pm
- Location: West of the Severn, UK
Re: Tables and CSS
Hi Nadia,
You can use !important in CSS to over-ride inline styles.
It is considered bad practice though. If you want a specific table it is usually better to insert an HTML Code Object instead. Sometimes this is the only way in H&M to get the exact column widths and spacings wanted. That's because the editor also has to provide for PDF, RTF and printed output (and RVF topic text).
You can use multiple HTML Code Objects to provide the <tr><td> tags, etc., with normal H&M editor text between them. This allows you to use the full H&M functionality, searching, etc.
Alternatively the Table Properties dialog allows you to specify an optional table ID. You could use javascript in the page onload event to modify a table to whatever you want. Or insert a <style> HTML Code Object below the table to modify the styles for that ID after the inline styles have been read.
You can use:
on narrow HTML tables to prevent the browser messing them up.
Martin.
You can use !important in CSS to over-ride inline styles.
Code: Select all
color:red !important;
You can use multiple HTML Code Objects to provide the <tr><td> tags, etc., with normal H&M editor text between them. This allows you to use the full H&M functionality, searching, etc.
Alternatively the Table Properties dialog allows you to specify an optional table ID. You could use javascript in the page onload event to modify a table to whatever you want. Or insert a <style> HTML Code Object below the table to modify the styles for that ID after the inline styles have been read.
You can use:
Code: Select all
table-layout:fixed;
Martin.
- Tim Green
- Site Admin
- Posts: 23184
- Joined: Mon Jun 24, 2002 9:11 am
- Location: Bruehl, Germany
- Contact:
Re: Tables and CSS
I would agree with Martin here, although I'm more relaxed about using !important. It's frequently the simplest and most effective solution when you are working with HTML and CSS code that you don't have direct control over yourself, which is definitely the case in any content management system liked Help+Manual. Purists may frown on it but there is no technical or standards reason not to use it, and as Buddha said, "The truth is what works."
Regards,
Tim (EC Software Documentation & User Support)
Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
Tim (EC Software Documentation & User Support)
Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
-
- Posts: 53
- Joined: Thu Sep 24, 2015 11:57 am
- Location: Moscow
Re: Tables and CSS
Hello Martin, Tim,
the fact is I also want a PDF even if it will have slightly different table settings, so HTML code object wouldn't work for me, would it? So for a little thing like different cell padding I'm going to go ahead and use !important. Thank you.
the fact is I also want a PDF even if it will have slightly different table settings, so HTML code object wouldn't work for me, would it? So for a little thing like different cell padding I'm going to go ahead and use !important. Thank you.
Omit needles swords
- Tim Green
- Site Admin
- Posts: 23184
- Joined: Mon Jun 24, 2002 9:11 am
- Location: Bruehl, Germany
- Contact:
Re: Tables and CSS
No, code objects don't work in PDF because to be able to they would need to be converted to something that works in PDF, which would mean having a parser that could understand everything that is possible in HTML, CSS and JS. Not practical.
Regards,
Tim (EC Software Documentation & User Support)
Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
Tim (EC Software Documentation & User Support)
Private support:
Please do not email or PM me with private support requests -- post to the forum directly.