1

I want to apply:

.page-item-124 a {
  font-size: 15px !important;
  font-weight: bold;
}

to all page items (classes starting with page-item) there are.

How can I do that?

Kyll
  • 7,036
  • 7
  • 41
  • 64
Dredglol
  • 13
  • 3
  • 1
    `font-size` is inherit property. so apply only to `body` tag. and no need of `!important`. – Mr_Green Nov 26 '15 at 10:53
  • 1
    OP said: `to all page items`. I hope he meant to all elements in that page. – Mr_Green Nov 26 '15 at 10:56
  • As the class name is `page-item-xxx` I assumed he meant the elements with class `page-item-[something]` ;) btw; we can't know if `!important` is needed. Probably he's overwriting template styles. – giorgio Nov 26 '15 at 11:02
  • that's exactly what i wanted to do @giorgio :) – Dredglol Nov 26 '15 at 11:06
  • 4
    Possible duplicate of [Is there a CSS selector by class prefix?](http://stackoverflow.com/questions/3338680/is-there-a-css-selector-by-class-prefix) – Thaillie Nov 26 '15 at 12:46

2 Answers2

2

You can use CSS3 [attribute*=value] Selector like this

Demo: https://jsfiddle.net/2Lzo9vfc/180/

HTML

<div class="page-item-1">Lorem ipsum</div>
<div class="page-item-2">Lorem ipsum</div>

CSS

div[class*="page-item"] {
  color: blue;
  font-size: 15px;
}
Nenad Vracar
  • 118,580
  • 15
  • 151
  • 176
  • You're welcome. Since you're new here, please don't forget to mark the answer accepted which helped most in solving the problem. See also How does accepting an answer work? – Nenad Vracar Nov 26 '15 at 11:06
  • If you want to use same class on other html element for example `a` your css selector should be like this `a[class*="page-item"]` but since you are using `div` you can use this selector `div[class*="page-item"]` – Nenad Vracar Nov 26 '15 at 11:12
0

You can use the starts with (^=) or wildcard (*=) attribute selector for that:

[class=^page-item] { font-size: 15px !important; font-weight: bold; }

This will select among others these elements:

<p class="page-item-123"></p>
<section class="page-item-intro"></section>

You might want to narrow it down a bit. Eg only select div elements.

div[class^=page-item] { ... }

See also selector documentation and the fiddle demo

giorgio
  • 10,111
  • 2
  • 28
  • 41