aboutsummaryrefslogtreecommitdiff
path: root/files/fa/web/css/attribute_selectors/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/fa/web/css/attribute_selectors/index.html')
-rw-r--r--files/fa/web/css/attribute_selectors/index.html182
1 files changed, 182 insertions, 0 deletions
diff --git a/files/fa/web/css/attribute_selectors/index.html b/files/fa/web/css/attribute_selectors/index.html
new file mode 100644
index 0000000000..54cf34cd5d
--- /dev/null
+++ b/files/fa/web/css/attribute_selectors/index.html
@@ -0,0 +1,182 @@
+---
+title: انتخابگر ویژگی
+slug: Web/CSS/انتخابگرـویژگی
+translation_of: Web/CSS/Attribute_selectors
+---
+<div>{{CSSRef}}</div>
+
+<p dir="rtl"><strong>انتخابگر ویژگی</strong> بر اساس وجود ویژگی یا مقدار ویژگی انتخاب می‌کند.</p>
+
+<pre class="brush: css no-line-numbers">/* را داشته باشند title که ویژگی &lt;a&gt; عنصرهای */
+a[title] {
+ color: purple;
+}
+
+/* باشد "https://example.org" آن برابر با href که ویژگی &lt;a&gt; عنصرهای */
+a[href="https://example.org"] {
+ color: green;
+}
+
+/* باشد "example" آن در بردارنده‌ی href که ویژگی &lt;a&gt; عنصرهای */
+a[href*="example"] {
+ font-size: 2em;
+}
+
+/* به پایان رسیده باشد ".org" آن با href که ویژگی &lt;a&gt; عنصرهای */
+a[href$=".org"] {
+ font-style: italic;
+}</pre>
+
+<dl>
+ <dt><code>[<em>attr</em>]</code></dt>
+ <dd>Represents elements with an attribute name of <em>attr</em>.</dd>
+ <dt><code>[<em>attr</em>=<em>value</em>]</code></dt>
+ <dd>Represents elements with an attribute name of <em>attr</em> whose value is exactly <em>value</em>.</dd>
+ <dt><code>[<em>attr</em>~=<em>value</em>]</code></dt>
+ <dd>Represents elements with an attribute name of <em>attr</em> whose value is a whitespace-separated list of words, one of which is exactly <em>value</em>.</dd>
+ <dt><code>[<em>attr</em>|=<em>value</em>]</code></dt>
+ <dd>Represents elements with an attribute name of <em>attr</em> whose value can be exactly <em>value</em> or can begin with <em>value</em> immediately followed by a hyphen, <code>-</code> (U+002D). It is often used for language subcode matches.</dd>
+ <dt><code>[<em>attr</em>^=<em>value</em>]</code></dt>
+ <dd>Represents elements with an attribute name of <em>attr</em> whose value is prefixed (preceded) by <em>value</em>.</dd>
+ <dt><code>[<em>attr</em>$=<em>value</em>]</code></dt>
+ <dd>Represents elements with an attribute name of <em>attr</em> whose value is suffixed (followed) by <em>value</em>.</dd>
+ <dt><code>[<em>attr</em>*=<em>value</em>]</code></dt>
+ <dd>Represents elements with an attribute name of <em>attr</em> whose value contains at least one occurrence of <em>value</em> within the string.</dd>
+ <dt id="case-insensitive"><code>[<em>attr</em> <em>operator</em> <em>value</em> i]</code></dt>
+ <dd>Adding an <code>i</code> (or <code>I</code>) before the closing bracket causes the value to be compared case-insensitively (for characters within the ASCII range).</dd>
+</dl>
+
+<h2 id="Examples">Examples</h2>
+
+<h3 id="Links">Links</h3>
+
+<h4 id="CSS">CSS</h4>
+
+<pre class="brush: css">a {
+ color: blue;
+}
+
+/* Internal links, beginning with "#" */
+a[href^="#"] {
+ background-color: gold;
+}
+
+/* Links with "example" anywhere in the URL */
+a[href*="example"] {
+ background-color: silver;
+}
+
+/* Links with "insensitive" anywhere in the URL,
+ regardless of capitalization */
+a[href*="insensitive" i] {
+ color: cyan;
+}
+
+/* Links that end in ".org" */
+a[href$=".org"] {
+ color: red;
+}
+</pre>
+
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html">&lt;ul&gt;
+ &lt;li&gt;&lt;a href="#internal"&gt;Internal link&lt;/a&gt;&lt;/li&gt;
+ &lt;li&gt;&lt;a href="http://example.com"&gt;Example link&lt;/a&gt;&lt;/li&gt;
+ &lt;li&gt;&lt;a href="#InSensitive"&gt;Insensitive internal link&lt;/a&gt;&lt;/li&gt;
+ &lt;li&gt;&lt;a href="http://example.org"&gt;Example org link&lt;/a&gt;&lt;/li&gt;
+&lt;/ul&gt;</pre>
+
+<h4 id="Result">Result</h4>
+
+<p>{{EmbedLiveSample('Links')}}</p>
+
+<h3 id="Languages">Languages</h3>
+
+<h4 id="CSS_2">CSS</h4>
+
+<pre class="brush: css">/* All divs with a `lang` attribute are bold. */
+div[lang] {
+ font-weight: bold;
+}
+
+/* All divs in US English are blue. */
+div[lang~="en-us"] {
+ color: blue;
+}
+
+/* All divs in Portuguese are green. */
+div[lang="pt"] {
+ color: green;
+}
+
+/* All divs in Chinese are red, whether
+ simplified (zh-CN) or traditional (zh-TW). */
+div[lang|="zh"] {
+ color: red;
+}
+
+/* All divs with a Traditional Chinese
+ `data-lang` are purple. */
+/* Note: You could also use hyphenated attributes
+ without double quotes */
+div[data-lang="zh-TW"] {
+ color: purple;
+}
+</pre>
+
+<h4 id="HTML_2">HTML</h4>
+
+<pre class="brush: html">&lt;div lang="en-us en-gb en-au en-nz"&gt;Hello World!&lt;/div&gt;
+&lt;div lang="pt"&gt;Olá Mundo!&lt;/div&gt;
+&lt;div lang="zh-CN"&gt;世界您好!&lt;/div&gt;
+&lt;div lang="zh-TW"&gt;世界您好!&lt;/div&gt;
+&lt;div data-lang="zh-TW"&gt;?世界您好!&lt;/div&gt;
+</pre>
+
+<h4 id="Result_2">Result</h4>
+
+<p>{{EmbedLiveSample('Languages')}}</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSS4 Selectors', '#attribute-selectors', 'attribute selectors')}}</td>
+ <td>{{Spec2('CSS4 Selectors')}}</td>
+ <td>Adds modifier for ASCII case-insensitive attribute value selection</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS3 Selectors', '#attribute-selectors', 'attribute selectors')}}</td>
+ <td>{{Spec2('CSS3 Selectors')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS2.1', 'selector.html#attribute-selectors', 'attribute selectors')}}</td>
+ <td>{{Spec2('CSS2.1')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("css.selectors.attribute")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>Selecting a single element: {{domxref("Document.querySelector()")}}, {{domxref("DocumentFragment.querySelector()")}}, or {{domxref("Element.querySelector()")}}</li>
+ <li>Selecting all matching elements: {{domxref("Document.querySelectorAll()")}}, {{domxref("DocumentFragment.querySelectorAll()")}}, or {{domxref("Element.querySelectorAll()")}}</li>
+ <li>The above methods are all implemented based on the {{domxref("ParentNode")}} mixin; see {{domxref("ParentNode.querySelector()")}} and {{domxref("ParentNode.querySelectorAll()")}}</li>
+</ul>