If this a situation.
p{margin-bottom:5px}
#top-textContainer p {margin-bottom:10px}
Is there a way to write this in a shorter way , or no other option
#board-committees #top-textContainer p,
#corporate-governance #top-textContainer p,
#corporate #top-textContainer p,
#about-us #top-textContainer p,
#contact us #top-textContainer p{margin-bottom:15px}
Can anyone suggest me better question heading and improve my questi开发者_如何学编程on?
What you failed to mention in your initial post is that since you are using a CMS, you don't have control over your HTML source files, only over your CSS.
You were also unclear about your aim, which is that from the 150 pages you have, you want some of them to have a paragraph with margin-bottom of 15px, but all the other pages to have 10px.
The answer under the abovementioned conditions:
No, there is no way to shorten the CSS code. Without adding specific class tags to your HTML, which you cannot do, there is no other way to distinguish the pages where you want 15px, from the pages where you want 10px, then what you have already done.
Exceptions to this rule:
- If the pages where you want the different margin, have some other specific characteristic, that could be selectable in CSS, you could base your selection on that and shorten the CSS code. For example, if your P would always be followed by a BR, or be part of an UL. But since I do not have your source, I don't know if it is possible.
- If your CMS offers the possibility to add custom class tags to pages or elements of your choice, you can refine your CSS based on the occurence of that particular class tag. But since I do not know your CMS, I also don't know if it is possible.
Set the margin-bottom
of every element (p
, #top-textContainer
, etc.) you mentioned to 5px? So the margins accumulates to the value you need.
精彩评论