DEV Community

FSCSS tutorials for FSCSS tutorials

Posted on • Edited on • Originally published at codepen.io

FSCSS Attribute selectors

FSCSS Attribute Selectors
Style HTML Elements With Specific Attributes
It is possible to style HTML elements that have specific attributes or attribute values.

FSCSS $(attribute:value) Selector
The $(attribute:value) selector is used to select elements with a specified attribute and value.

The following example selects all elements with a target="_blank" attribute:

Example

a$(target:_blank) {
  background-color: yellow;
}
Enter fullscreen mode Exit fullscreen mode

FSCSS $(attribute~:value) Selector
The $(attribute~:value) selector is used to select elements with an attribute value containing a specified word.

The following example selects all elements with a title attribute that contains a space-separated list of words, one of which is "flower":

Example

$(title~:flower) {
  border: 5px solid yellow;
}
Enter fullscreen mode Exit fullscreen mode

The example above will match elements with title="flower", title="summer flower", and title="flower new", but not title="my-flower" or title="flowers".

FSCSS $(attribute|:value) Selector
The $(attribute|:value) selector is used to select elements with the specified attribute, whose value can be exactly the specified value, or the specified value followed by a hyphen (-).

Note: The value has to be a whole word, either alone, like class="top", or followed by a hyphen( - ), like class="top-text".

Example

$(class|:top) {
  background: yellow;
}
Enter fullscreen mode Exit fullscreen mode

FSCSS $(attribute^:value) Selector
The $(attribute^:value) selector is used to select elements with the specified attribute, whose value starts with the specified value.

The following example selects all elements with a class attribute value that starts with "top":

Note: The value does not have to be a whole word!

Example

$(class^:top) {
  background: yellow;
}
Enter fullscreen mode Exit fullscreen mode

FSCSS $(attribute$:value) Selector
The $(attribute$:value) selector is used to select elements whose attribute value ends with a specified value.

The following example selects all elements with a class attribute value that ends with "test":

Note: The value does not have to be a whole word!

Example

$(class$:test) {
  background: yellow;
}
Enter fullscreen mode Exit fullscreen mode

FSCSS $(attribute*:value) Selector
The $(attribute*:value) selector is used to select elements whose attribute value contains a specified value.

The following example selects all elements with a class attribute value that contains "te":

Note: The value does not have to be a whole word!

Example

$(class*:te){
  background: yellow;
}
Enter fullscreen mode Exit fullscreen mode

Styling Forms
The attribute selectors can be useful for styling forms without class or ID:

Example

input$(type: text) {
  width: 150px;
  display: block;
  margin-bottom: 10px;
  background-color: yellow;
}

input$(type: button){
  width: 120px;
  margin-left: 35px;
  display: block;
}
Enter fullscreen mode Exit fullscreen mode

🎁Thanks for reading.
Learn more about FSCSS.
Best on version 4.0.1:
Link: https://combinatronics.io/Figsh/FSCSS/refs/heads/4.0.1/fscss_exec.js

<script src='https://combinatronics.io/Figsh/FSCSS/refs/heads/4.0.1/fscss_exec.js' async=""></script>
<style>
$Body-bg-stack: #00f linear-gradient(#00f0f0, #99f9f9) No-repeat;
$primary-color: midnightblue;
Body{
Background: $Body-bg-stack;
Color: $primary-color;
-*-text-stroke: 0.1px red;
} 
</style>
Enter fullscreen mode Exit fullscreen mode

FSCSS code

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more