Styling attributes nested inside id and class - css

What I want to do is remove the margin for the p nested inside the id then class.
Please note I cannot add a direct id or class for this p since this is a Wordpress site.

Something like this I believe is what you're looking for
.textwidget p
{
margin: 0;
}
or if you specifically need that first paragraph tag
.textwidget p:first-child
{
margin: 0;
}

You need to use the #id, .class, p and possibly :first-child selectors, like this:
#panel-w59fa3473baf71-0-1-0 .textwidget p:first-child {
/* your styles */
}
Keep in mind that id might change since this is a Wordpress site. If that's the case you'll need to use one of the classes on that same element. Like:
.so-panel .textwidget p:first-child {
/* your styles */
}

Actually it was my mistake, i have prefixed the p with a (.)
/*Style header whatsapp area*/
#panel-w59fa3473baf71-0-0-0 .textwidget p{
margin:0px;
}
#panel-w59fa3473baf71-0-1-0 .textwidget p{
margin:0px;
}

Related

CSS page-id child

I need to style element by page-id. I use for it this:
.page-id-34 .gallery-columns-9 .gallery-item { }
It is possible to style the same, but in relation to all child of page id 34?
Use a wildcard to match all descendants of an element:
.page-id-34 * {
color: red;
}
If you want to style only direct div elements for example it would be
.page-id-34 > div {
color: red;
}
I just got to that. I use:
.parent-pageid-34 .gallery-columns-9 .gallery-item { }
and it works!
Thank you for your participation.

Multiple class selecting in CSS

.upload header {...}
Styling will be applied to any header that is a child of any element with class of '.upload'.
Is it possible to do this?
.upload header, form {...}
Or will I have to specify the class for every type selector ?
You can't do that. The comma for selector works like the following:
div > nav,
p {
display: block;
}
Is exactly the same as writting
div > nav { display: block; }
p { display: block; }
The comma is used to re-use rules, but each selector is global, and does not use the same parent.
In your case, if you want to make the rule only apply to those form elements that are children of .upload, you would have to do
.upload header, .upload form {...}
You could do this with two selectors. First set your styles with * and then reset the same styles if you only want it to be applied to the first child element.
.upload *:first-child {
background: blue;
}
.upload *:first-child *:first-child {
background: none;
}

what is the way to child element not inherit parents property?

what is the way to child element not inherit parents property?
I know way to child element declare individually property.
I curious that people use another way.
You can either set some styles only for that element:
p{ color:red; }
or overwrite the default inherited styles (like margin in this case):
p{ margin: 0; }
or, in some contexts add a class or an id to add more weight to the selector (adding an id to the p):
div p{ color: blue; }
#myParagraph{ color: red; }
This could be a way
div{
padding:10px;
}
div *{
padding: 0px;
}
But its highly NOT RECOMMENDED for elements with many children

LESS apply styles to element and its children

I have an element, page-header that I want to remove the margins from. That element also has a child h1 that I also want to remove the margin from. Is there a shortcut syntax in LESS that allows me to do this.
Right now I have this:
.page-header,
.page-header h1{
margin:0;
}
But I'm curious if there's something like:
.page-header &+ h1{
margin:0;
}
that, when rendered, will give me CSS like my first code block above. &+ doesn't work, I checked
The ampersand can only be used with nesting:
.page-header {
&, & h1{
margin:0;
}
}
For more information, see my blog post.

Styling All Anchor Tags Within A <td> Element

i already have a css section:
.leftMemberCol
{
width:125px;
vertical-align:top;
padding: 13px;
border-width:0px;
border-collapse:separate;
border-spacing: 10px 10px;
text-align:left;
background-color:#f2f3ea;
}
for a td section (a left side bar). I want to make all of the links inside this cell be the color green.
is there any syntax like:
.leftMemberCol.a
{
color:#E3E3CA;
}
or any other suggestions instead of having to go to each page and wrapping all the links around another class name.
Just do:
.leftMemberCol a
{
color:#E3E3CA;
}
That will select all anchor tags nested within the element with the class of .leftMemberCol
If the color doesn't work, check if you set it earlier on in your CSS file for any of the pseudo selectors of the a tag, i.e. a:link etc.
override them using
.leftMemberCol a:link,
.leftMemberCol a:hover,
.leftMemberCol a:visited,
.leftMemberCol a:active
{
color: #E3E3CA;
}
replace the last dot with a space
.leftMemberCol a {
style goes here
}
The dot indicates a class. A hash indicates an id (
<div id="home">
can be styled with
#home { }
). A regular html element, like a td or a doesn't need a prefix.
.leftMemberCol a
{
color:#E3E3CA;
}
should do the trick.
You are very close. This is how you select the links inside the cell:
.leftMemberCol a
{
color: #E3E3CA;
}
You can read more about selectors here.
Edit:
If the style doesn't take effect, it's probably because you have some other style defined for the links that is more specific. You can make the style more specific by adding specifiers, for example:
td.leftMemberCol a
{
color: #E3E3CA;
}
As a last resort you can also use the !important directive:
.leftMemberCol a
{
color: #E3E3CA !important;
}
.leftMemberCol>a
{
color:#E3E3CA;
}
.leftMemberCol a
{
color:#E3E3CA;
}
This targets all <a> elements that are descendents of .leftMemberCol

Resources