<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>J.P. McGarrity.com &#187; Attribute selectors</title>
	<atom:link href="http://jpmcgarrity.com/blog/tag/attribute-selectors/feed/" rel="self" type="application/rss+xml" />
	<link>http://jpmcgarrity.com/blog</link>
	<description>Focusing on the Front End</description>
	<lastBuildDate>Sat, 30 Apr 2011 16:40:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Advanced CSS Attribute Selector Demo</title>
		<link>http://jpmcgarrity.com/blog/2010/03/advanced-css-attribute-selector-demo/</link>
		<comments>http://jpmcgarrity.com/blog/2010/03/advanced-css-attribute-selector-demo/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 19:22:09 +0000</pubDate>
		<dc:creator>J.P.</dc:creator>
				<category><![CDATA[CSS 3]]></category>
		<category><![CDATA[css/xhtml]]></category>
		<category><![CDATA[Attribute selectors]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://jpmcgarrity.com/blog/?p=597</guid>
		<description><![CDATA[Recently a back end developer asked me with there was a way to use a wild card in CSS that would allow him to generate ID&#8217;s on the fly. The solution I came up with was to use an attribute selector.
When using attribute selectors in CSS the name before the &#8220;&#124;&#8221; is the attribute targeted. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently a back end developer asked me with there was a way to use a wild card in CSS that would allow him to generate ID&#8217;s on the fly. The solution I came up with was to use an attribute selector.</p>
<p>When using attribute selectors in CSS the name before the &#8220;|&#8221; is the attribute targeted. In this case &#8220;id&#8221; is used but we could have just as easily used &#8220;rel&#8221;, &#8220;input&#8221;, &#8220;value&#8221; etc.</p>
<p>The text after the &#8220;|&#8221; is what the attribute must start with to be read. The example uses &#8220;section&#8221;. Each &#8220;id&#8221; in the html that starts with &#8220;section&#8221; will be styled. Some id&#8217;s use more specific code in certain div&#8217;s to give them unique colors showing how the cascading works in the CSS file.</p>
<p>Here is the solution:</p>
<p><a href="http://jpmcgarrity.com/examples/css/advanced_css_attributes/">View the Demo</a></p>
<p><strong>CSS Code</strong><br />
<code>[id|="section"]{<br />
					border: 10px solid #999;<br />
					margin:10px 0;<br />
					background:black;<br />
					width:	200px;<br />
					height:	200px;<br />
				}<br />
[id|="section-item"]{<br />
					background:green;<br />
				}<br />
#section-1{<br />
					background:red;<br />
				}<br />
#section-2{<br />
					background:blue;<br />
				}<br />
#section-3{<br />
					background:yellow;<br />
				}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://jpmcgarrity.com/blog/2010/03/advanced-css-attribute-selector-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Attribute Selectors</title>
		<link>http://jpmcgarrity.com/blog/2009/08/css-attribute-selectors/</link>
		<comments>http://jpmcgarrity.com/blog/2009/08/css-attribute-selectors/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 13:10:02 +0000</pubDate>
		<dc:creator>J.P.</dc:creator>
				<category><![CDATA[css/xhtml]]></category>
		<category><![CDATA[Attribute selectors]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://jpmcgarrity.com/blog/?p=478</guid>
		<description><![CDATA[
CSS Attribute selectors are a great way to target specific elements in your page and apply styles to them with out have go back and opening up the template file and changing code.
I find them extremely useful for creating form css.
There are 6 different types of attribute selectors

[att=value]
The attribute has to have the exact value [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-489" title="computer_controls" src="http://jpmcgarrity.com/blog/wp-content/uploads/2009/08/computer_controls1.jpg" alt="computer_controls" width="500" height="323" /></p>
<p>CSS Attribute selectors are a great way to target specific elements in your page and apply styles to them with out have go back and opening up the template file and changing code.</p>
<p>I find them extremely useful for creating form css.</p>
<h4>There are 6 different types of attribute selectors</h4>
<ul>
<li>[att=value]<br />
The attribute has to have the exact value specified.</li>
<li>[att~=value]<br />
The attribute’s value needs to be a whitespace separated list of words (for example, class=”title featured home”), and one of the words is exactly the specified value.</li>
<li>[att|=value]<br />
The attribute’s value is exactly “value” or starts with the word “value” and is immediately followed by “-”, so it would be “value-”.</li>
<li>[att^=value]<br />
The attribute’s value starts with the specified value.</li>
<li>[att$=value]<br />
The attribute’s value ends with the specified value.</li>
<li>[att*=value]<br />
The attribute’s value contains the specified value.</li>
</ul>
<p>Here is an <a href="http://jpmcgarrity.com/examples/css/css_attributes/index.html">example page</a> where I have formatted elements with attribute selectors only.</p>
<h4>Sample CSS Used</h4>
<p><code style="height:500px">			&lt;style type="text/css" media="screen"&gt;<br />
			p[tile='para1'] {<br />
				color:red;<br />
				}<br />
			input[type="text"] {<br />
				width: 200px;<br />
				background-color: #DDD;<br />
				border:0px;<br />
				display:block;<br />
				padding:3px;<br />
				}<br />
			input[type="submit"] {<br />
				width: 200px;<br />
				background-color: #000;<br />
				border:0px;<br />
				display:block;<br />
				padding:5px;<br />
				color:#fff;<br />
				margin-top:5px;<br />
				}<br />
			a[href$='.jpg']{<br />
				background:green;<br />
				color:#fff;<br />
			}<br />
			&lt;/style&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://jpmcgarrity.com/blog/2009/08/css-attribute-selectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

