03 – СSS селекторы – Селектор по названию атрибута

There are global attributes in CSS, and there are attributes specific to some elements, and there are attributes that are generally created by the developers themselves So, for any of them, you can find the HTML elements you need, just use the attribute selector. It is written in square brackets and the name of your attribute follows Let’s create four elements, three blocks and make one paragraph so that two of them will have a title attribute and one of them will have a custom data-my attribute that looks something like this If you hover over the first element with a mouse, we’ll see a tooltip Now let’s write a CSS rule that will select all elements that have a title attribute. It looks like this, the title is written in square brackets and our elements are immediately highlighted.
If you want to clarify that only div elements with the title attribute were painted, then you need to add the tag names in front of the square brackets. To find the third block in line 11 you will have to write the name of the data-my attribute Now you have colored and the element in line 11. If you liked this video, please like it! Happy development and all the best!

Add a Comment

Your email address will not be published. Required fields are marked *