Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All tags that start with

Tags:

html

css

frontend

Is there any way to to specify styling for all tags that start with some prefix?

For example:

tst-* {
  display: block;
  background: yellow;
}

<tst-some-tag>Some content</tst-some-tag>


The reason why I want such selector is because I'm using Angular and have lots of custom components. All of them should be displayed as block. It could be very comfortable to specify display property for all custom elements ones, instead of adding class every time, when I use them.

like image 305
ReasonX7 Avatar asked Nov 24 '16 11:11

ReasonX7


1 Answers

If you want to select elements by class-name you could do this: [class^='class']

If you want to select elements by id simply do this: [id^='id']

In both cases you select all elements witch start with the text you put between the single quotation marks, either by class-name or by id.

Variations are also possible: div[class^='class'] or div[id^='id']

like image 52
to7be Avatar answered Nov 15 '22 02:11

to7be