CSS attribute begins with a carriage

Many CSS attributes in the project that I am currently supporting begin with a caret ^ as follows:

 <tr style="^padding-bottom: 10px;"> 

Does carriage make sense? Perhaps a fix for some obscure browser? Or is it just a typo from a previous developer who was copied x times (since it is always present along with "padding-bottom")?

+6
source share
2 answers

Styles with a carriage in front of them are not applied. So this could be a way to comment on CSS styles in this case without using whole HTML comments. This is not a standard way to do this, though.

(Example)


The caret character in CSS makes sense of the β€œStart with” attribute selector .

It allows you to customize an element in your CSS based on whether the attribute value begins with a given string.

 E[foo] an E element with a "foo" attribute E[foo="bar"] an E element whose "foo" attribute value is exactly equal to "bar" E[foo~="bar"] an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar" E[foo^="bar"] an E element whose "foo" attribute value begins exactly with the string "bar" E[foo$="bar"] an E element whose "foo" attribute value ends exactly with the string "bar" E[foo*="bar"] an E element whose "foo" attribute value contains the substring "bar" 

However, in your case, the carriage does not work as a selector.

+6
source

Yes, carriage makes sense in CSS 3, it is an attribute selector in CSS 3. This selector allows the presentation of an attribute of an element. When a selector is used as an expression to match an element, the attribute selector should be considered as matching the element if this element has an attribute that matches the attribute represented by the attribute selector .

But in your case, it could be a typo.

CSS3 Attribute Segments - Matching

Three of the attribute selectors in the CSS3 specification allow you to check the value of a specified attribute to match a string. These attribute selectors are called substring matching attribute selectors .

[ATT ^ = value]

Represents an element with the att attribute, the value of which begins with the prefix "val". If "val" is an empty string, the selector does not represent anything.

[ATT $ = value]

Represents an element with the attribute att, the value of which ends with the suffix "val". If "val" is an empty string, the selector does not represent anything.

[ATT * = value]

Represents an element with the attribute att whose value contains at least one instance of the substring "val". If "val" is an empty string, the selector does not represent anything.

+4
source

Source: https://habr.com/ru/post/921915/


All Articles