Computer >> Computer tutorials >  >> Programming >> HTML

Applying a CSS style to an ID element when the beginning of its name stays identical and the end varies in HTML


Posts can be selected using div with ‘id=post’. This will select all div elements with an id which contains a value in quotes.

We can use either −

div[id*='post-'] { ... } or div[id^='post-'] { ... }.

div[id*='post-'] { ... } will select all div elements with id which is having all values in quotes.

Or we can use,

div[id^='post-'] { ... }

This will select all div elements with an id which started with quotes.