<?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>onenaught.com &#187; CSS</title>
	<atom:link href="http://www.onenaught.com/posts/category/css/feed" rel="self" type="application/rss+xml" />
	<link>http://www.onenaught.com</link>
	<description>A blog on web standards, accessibility, css, javascript, xslt, and more</description>
	<lastBuildDate>Fri, 30 Jul 2010 13:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<image>
		<title>One Naught</title>
		<url>http://www.onenaught.com/wp-content/themes/onenaught/images/onenaught.png</url>
		<link>http://www.onenaught.com</link>
		<width>116</width>
		<height>130</height>
		<description>OneNaught.com</description>
	</image>		<item>
		<title>CSS: inner elements breaking border-radius</title>
		<link>http://www.onenaught.com/posts/266/css-inner-elements-breaking-border-radius</link>
		<comments>http://www.onenaught.com/posts/266/css-inner-elements-breaking-border-radius#comments</comments>
		<pubDate>Thu, 09 Jul 2009 08:34:39 +0000</pubDate>
		<dc:creator>Anup Shah</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[General Web Development]]></category>

		<guid isPermaLink="false">http://www.onenaught.com/?p=266</guid>
		<description><![CDATA[Some browsers support border-radius for rounded corners. But inner elements may break those corners. Sometimes, applying border-radius to those inner elements can resolve the issue.]]></description>
			<content:encoded><![CDATA[<p>Browsers such as Firefox 2+ and Webkit-based browsers (Chrome, Safari) support the useful css <a href="http://www.w3.org/TR/2005/WD-css3-background-20050216/#the-border-radius">border-radius</a> feature (via -moz-border-radius and -webkit-border-radius, respectively).</p>
<p>Unfortunately inner elements can break rounded borders as Richard Rutter described when <a href="http://clagnut.com/blog/2273/">using <code>&lt;img&gt;</code> elements inside an element with <code>border-radius</code></a>. He also provided a useful solution which is webkit only, unfortunately.</p>
<p>Inner elements with background colors can also break border-radius. But there is a way around that too: <strong>apply <code>border-radius</code> to the offending inner elements too</strong>.</p>
<h3 id="toc-the-problem">The problem</h3>
<p>Here&#8217;s an example (view in Firefox 2+ or Safari/Chrome) where <code>border-radius</code> gets broken:</p>
<p>(If you are reading this in an RSS feed reader, you might need to <a href="http://www.onenaught.com/posts/266/css-inner-elements-breaking-border-radius">go to the page to see the example properly</a>)</p>
<p>A <code>div</code> containing a <code>blockquote</code> and a paragraph to mention the source of the quote:</p>
<div class="blockquote-with-source">
<blockquote>
<p>Fear is the path to the Dark Side&#8230; Fear leads to anger&#8230; anger leads to hate&#8230; hate leads to suffering&#8230;</p>
</blockquote>
<p class="source">— Yoda, <cite>Star Wars, Episode 1: The Phantom Menace</cite></p>
</div>
<p>Notice the bottom corners aren&#8217;t right: the background of the source paragraph breaks through the rounded corners.</p>
<p>The rounded corners are achieved using something like this:</p>
<pre class="syntax-highlight:css">
.blockquote-with-source {
  border:1px solid #e8eac8;
  border-radius:10px;
  -moz-border-radius:10px;
  -webkit-border-radius:10px;
}
</pre>
<p>(The above code is of course slightly more than necessary due to both mozilla and webkit implementing them via their rendering prefixes.)</p>
<h3 id="toc-the-ideal-solution">The ideal solution</h3>
<p><code>overflow:hidden</code> on inner elements should do the trick, but doesn&#8217;t work in Safari, Chrome or Firefox (although will work for the webkit-based ones for images as Richard Rutter points out in the above link).</p>
<h3 id="toc-workaround-for-non-image-elements-with-backgrounds">Workaround for non-image elements with backgrounds</h3>
<p>There are a few ways to work around this:</p>
<h4 id="toc-apply-border-radius-to-the-inner-element-breaking-the-rounded-corners">Apply border-radius to the inner element breaking the rounded corners</h4>
<p>If you are using background color (or background image) on the inner HTML element, you can apply <code>border-radius</code> to them too:</p>
<p>In the case of the above example, we just need rounded corners on the bottom left and bottom right of the source paragraph:</p>
<pre class="syntax-highlight:css">
.source {
    border-radius-bottomleft:10px;
    border-radius-bottomright:10px;
    -moz-border-radius-bottomleft:10px;
    -moz-border-radius-bottomright:10px;
    -webkit-border-bottom-left-radius:10px;
    -webkit-border-bottom-right-radius:10px;
}
</pre>
<p>The final styled quote would then look like this:</p>
<div class="blockquote-with-source">
<blockquote>
<p>Fear is the path to the Dark Side&#8230; Fear leads to anger&#8230; anger leads to hate&#8230; hate leads to suffering&#8230;</p>
</blockquote>
<p class="source with-fix">— Yoda, <cite>Star Wars, Episode 1: The Phantom Menace</cite></p>
</div>
<p>(If you inspect the above with Firebug or equivalent, you&#8217;ll notice I used slightly different CSS classes so it just fits with the current theme on this blog, but the principle is the same.)</p>
<h5 id="toc-drawback-to-the-above-workaround">Drawback to the above workaround</h5>
<p>The main one I can think of is that you have to maintain the border radius value in more than one place &#8212; CSS variables would be nice here <img src='http://www.onenaught.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h4 id="toc-thick-enough-borders-hide-the-problem">Thick enough borders hide the problem</h4>
<p>If your design allows it, thick borders on the element using border-radius may do the trick.</p>
<p>In the example below, I use a thick border on the left side of the containing div, with border radius only on the bottom right of the source paragraph:</p>
<div class="blockquote-with-source with-thick-left-border">
<blockquote>
<p>Fear is the path to the Dark Side&#8230; Fear leads to anger&#8230; anger leads to hate&#8230; hate leads to suffering&#8230;</p>
</blockquote>
<p class="source with-fix">— Yoda, <cite>Star Wars, Episode 1: The Phantom Menace</cite></p>
</div>
<p>The thickness of the border is the same as the size of the radius, though you don&#8217;t have to do that.</p>
<h5 id="toc-drawback-to-the-above-workaround1">Drawback to the above workaround</h5>
<p>When using one thick border as above, it doesn&#8217;t render as nicely in webkit as it does in gecko. Don&#8217;t know if that is vagueness in the spec, or what&#8230;</p>
<p>However, if all four borders are given the same width, then it seems ok.</p>
<h3 id="toc-workaround-for-image-elements">Workaround for image elements</h3>
<p>As Richard Rutter commented, putting an image as a CSS background image would do the trick, but that isn&#8217;t always ideal or possible (e.g. an image that is important as part of the content is better marked up as <code>&lt;img&gt;</code>).</p>
<p>Are there other, perhaps better, ways to deal with this?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onenaught.com/posts/266/css-inner-elements-breaking-border-radius/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Use CSS display:table for Layout</title>
		<link>http://www.onenaught.com/posts/201/use-css-displaytable-for-layout</link>
		<comments>http://www.onenaught.com/posts/201/use-css-displaytable-for-layout#comments</comments>
		<pubDate>Sun, 15 Feb 2009 22:34:38 +0000</pubDate>
		<dc:creator>Anup Shah</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[General Web Development]]></category>

		<guid isPermaLink="false">http://www.onenaught.com/?p=201</guid>
		<description><![CDATA[<img class="post-img" align="left" src="/wp-content/uploads/ffx-css-display-table-post-img.jpg" alt="" /> For a few years now, web developers doing CSS-based layouts have used floats or absolute positioning for layout web sites to avoid using non-semantic HTML <code>&#60;table&#62;</code>s.

While doable, extra hoops often have to be jumped through (mostly for IE) and some seemingly simple things can be harder than necessary (like equal height columns).

However, for a simpler solution, CSS-based <code>display:table</code>, <code>display:table-row</code>, <code>display:table-cell</code> etc are all usable today across Firefox 2+, Safari 3+, Opera 9+ and IE8.]]></description>
			<content:encoded><![CDATA[<p><img class="post-img" src="http://www.onenaught.com/wp-content/uploads/ffx-css-display-table-post-img.jpg" alt="" /> I had this post in draft since October 2008. I thought I&#8217;d redesign this blog site using <code>display:table</code> and explain that in a series of posts, starting with this one. But I never found the time for the redesign! </p>
<p>Still, I have been using <code>display:table</code> on a much larger site for about 6 months now, so I thought I might as well post this as it is, and perhaps follow up with more examples later.</p>
<p>Also, about 3 weeks after I started this draft, <a href="http://www.digital-web.com/articles/everything_you_know_about_CSS_Is_wrong/">Rachel Andrew and Kevin Yank wrote a book on CSS <code>display:table</code> for layout, as well as a useful summary article</a>! I do recommend looking at that article for finer details.</p>
<h3 id="toc-no-need-for-css-float-for-layout-in-modern-browsers">No need for css float for layout in modern browsers</h3>
<p>For a few years now, web developers doing CSS-based layouts have used floats or absolute positioning for layout web sites to avoid using non-semantic HTML <code>&lt;table&gt;</code>s.</p>
<p>While doable, extra hoops often have to be jumped through (mostly for IE) and some seemingly simple things can be harder than necessary (like equal height columns).</p>
<p>However, for a simpler solution, CSS-based <code>display:table</code>, <code>display:table-row</code>, <code>display:table-cell</code> etc are all usable today across Firefox 2+, Safari 3+, Opera 9+ and IE8.</p>
<p>Example:</p>
<p>Consider the following HTML:</p>
<pre class="syntax-highlight:html">
&lt;body&gt;
	&lt;div id=&quot;header&quot;&gt;
		&lt;!-- header --&gt;
	&lt;/div&gt;

	&lt;div id=&quot;content-body-wrapper&quot;&gt;
		&lt;div id=&quot;content-body&quot;&gt;
			&lt;div id=&quot;primary-nav&quot;&gt;
				&lt;!-- some navigation column here --&gt;
			&lt;/div&gt;
			&lt;div id=&quot;secondary-nav&quot;&gt;
				&lt;!-- some additional column here --&gt;
			&lt;/div&gt;
			&lt;div id=&quot;content&quot;&gt;
				&lt;!-- main content here --&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;

	&lt;div id=&quot;footer&quot;&gt;
		&lt;!-- footer --&gt;
	&lt;/div&gt;
&lt;/body&gt;
</pre>
<p>And the CSS to style it to get equal height columns:</p>
<pre class="syntax-highlight:css">
#content-body-wrapper {
    display:table;
    border-collapse:collapse;
}

#content-body {
    display:table-row;
}

#primary-nav, #secondary-nav, #content {
    display:table-cell;
}

#primary-nav, #secondary-nav {
    width:20%;
}

#content {
    width:60%;
}
</pre>
<p>And that&#8217;s it!</p>
<p>The above is just the layout bit of the CSS. Here are some screenshots (click for full size) with content and very basic styling just to see the equal height column effect:</p>
<p><a href='/wp-content/uploads/ffx-css-display-table.jpg' title='ffx-css-display-table'><img src="http://www.onenaught.com/wp-content/uploads/ffx-css-display-table-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a> <a href='/wp-content/uploads/ie8-css-display-table.jpg' title='ie8-css-display-table'><img src="http://www.onenaught.com/wp-content/uploads/ie8-css-display-table-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a></p>
<p>The first is with Firefox 3 and the second with IE8.</p>
<p>You can actually omit extra divs, even the one that gets display:table and the browser is required to create an anonymous table for you.</p>
<h3 id="toc-isnt-using-table-for-layout-wrong">Isn&#8217;t using table for layout wrong?</h3>
<p>This is not the same as using the <em>structural</em> html table elements for layout purposes &#8212; that indeed is an inappropriate use for tables.</p>
<p>This is using CSS to give table-like <em>display</em>, which is fine as it leaves the HTML (and document structure) in tact.</p>
<h3 id="toc-what-about-ie-7-and-6">What about IE 7 and 6?</h3>
<p>IE7 and 6 of course remain problems, but you can use conditional comments and give them older techniques that attempt to achieve this.</p>
<h3 id="toc-some-limitations-or-issues">Some limitations or issues</h3>
<p>Some limitations of css display:table I have come across, however, include these:</p>
<ul>
<li>Lack of colspan/rowspan equivalents</li>
<li>Like HTML tables, a CSS cell can expand in width based on content (as well as height).</li>
</ul>
<p>On the last one I noticed this when using things like <code>&lt;pre&gt;</code> even with overflow:auto with the thought that just like inside floated columns with widths assigned this would result in those <code>&lt;pre&gt;</code> blocks getting horizontal scrolls if they became too wide.</p>
<p>Instead, as with HTML tables, they push out the cell they are in. The only workaround I knew to this was to give a px or em width to such elements. (It also applies to large images in a cell.)</p>
<p>That being said, <code>display:table</code> seems a lot cleaner!</p>
<p>CSS3 has an advanced layout module in the works but there are not any browser implementations of it (that I am aware of), so in the interim this could be a useful approach.</p>
<h3 id="toc-more-info">More info</h3>
<ul>
<li><a href="http://www.w3.org/TR/CSS21/tables.html">W3C specifications on CSS display:table</a></li>
<li><a href="http://www.digital-web.com/articles/everything_you_know_about_CSS_Is_wrong/">Rachel Andrew: Everything you know about CSS is wrong</a></li>
</ul>
<h3 id="toc-translations">Translations</h3>
<p>Update: May 2010. Translated into <a href="http://pc.de/pages/vykarystanne-css-display-table">Belorussian</a>, by <a href="http://pc.de/">PC.de</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onenaught.com/posts/201/use-css-displaytable-for-layout/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Hiding Content on Web Pages for Accessibility</title>
		<link>http://www.onenaught.com/posts/35/hiding-content-on-web-pages-for-accessibility</link>
		<comments>http://www.onenaught.com/posts/35/hiding-content-on-web-pages-for-accessibility#comments</comments>
		<pubDate>Mon, 05 Nov 2007 22:23:28 +0000</pubDate>
		<dc:creator>Anup Shah</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.onenaught.com/posts/35/hiding-content-on-web-pages-for-accessibility</guid>
		<description><![CDATA[Web pages often benefit from some text that may not be necessary from a visual design perspective, but offer additional context to say blind users using a screen reader. Some CSS techniques to achieve this include moving text off the screen in such a way that screen readers will still read them out. However, there is a concern that search engines may not like this technique as it could be abused for keyword stuffing and other such practices. What are the implications?]]></description>
			<content:encoded><![CDATA[<h3 id="toc-move-text-off-the-screen-not-displaynone">Move text off the screen, not display:none</h3>
<h4 id="toc-why-bother">Why bother?</h4>
<p>Visual designs often require hiding text in such a way that screen readers will still read the text and thus provide extra context for the screen reader user.</p>
<p>For example, a visual design may make the main navigation section of the page obvious and so a heading to announce it may be unnecessary or undesirable.</p>
<p>However, from the perspective of good document structure/semantics and accessibility, it would be good to have the heading in there.</p>
<p>Screen reader users, for example, often scan a page through having a list of headings being read out to them.</p>
<h4 id="toc-the-problem-of-displaynone-in-css">The problem of <code>display:none</code> in CSS?</h4>
<p><code>display:none</code> in CSS would seem ideal (plus some additional rules in an aural stylesheet, perhaps).</p>
<p>Unfortunately, screen readers are inconsistent in the way they handle <code>display:none</code>.</p>
<p>In addition, most do not yet support the aural stylesheet sufficiently.</p>
<h4 id="toc-positioning-text-off-the-screen-is-more-reliable">Positioning text off the screen is more reliable</h4>
<p>For years, I have been using an &#8220;off-top&#8221; technique whereby content can be moved off the top of the screen, in such a way that it will still be read out by screen readers. Here is an example:</p>
<pre class="syntax-highlight:css">
.css-label {
    height:1px;
    left:0px;
    overflow:hidden;
    position:absolute;
    top:-500em;
    width:1px;
}
</pre>
<p>A simple example of using the above may be to provide a header to a section such as the navigation:</p>
<pre class="syntax-highlight:html">
&lt;h2 class="css-label"&gt;Navigation&lt;/h2&gt;
</pre>
<p>Some use use an &#8220;off-left&#8221; approach instead, though it seems to cause the odd problems with earlier versions of Opera and Safari (any one using those anymore?)</p>
<p>That being said, a comment left on <a href="http://juicystudio.com/article/screen-readers-display-none.php">Gez Lemon&#8217;s post about display:none issues</a> answers my question of whether off-top is better or not than off-left saying there may be some issues with off-top. I&#8217;ll need to look into that further, but either of those are certainly better than using display:none.</p>
<h4 id="toc-more-information">More information</h4>
<p>For further reading, see the following:</p>
<ul>
<li><a href="http://www.abilitynet.org.uk/webarticle67">Hiding Content from View</a>, AbilityNet, November 2007</li>
<li><a href="http://juicystudio.com/article/screen-readers-display-none.php">Screen Readers and display: none</a>, Gez Lemon, Juicy Studio, 12 October, 2007</li>
</ul>
<h3 id="toc-will-search-engines-see-this-as-keyword-stuffing">Will search engines see this as keyword stuffing?</h3>
<p>A comment left on Gez Lemon&#8217;s post asked what would be the impact on search engine listing? </p>
<p>Comments are closed on that post, so I will try to answer it here, as it is something I have been wondering for a long time.</p>
<p>The concern from an SEO point of view is that search engines may think you are tricking them even though this is a legitimate techniques for a legitimate purpose. However, some people could use these techniques for keyword stuffing, thus putting this useful technique in jeopardy and making it harder to provide sufficient context to assistive technologies.</p>
<h4 id="toc-search-engines-would-likely-have-a-hard-time-detecting-this-in-an-automated-manner">Search engines would likely have a hard time detecting this in an automated manner</h4>
<p>But for search engines to detect this they would at least need to parse all the CSS. Then, they would have to looking for all the different permutation of these rules and be 100% sure this is being done for keyword stuffing and not for some other legitimate reason.</p>
<p>Sounds tricky (and easy to circumvent &#8212; e.g. by using JavaScript to set these styles, as it is only being hidden from visual user agents).</p>
<p>Or, search engines would need to implement an entire DOM and calculate where on a screen all the text would go. Some major web browsers struggle to do this properly, so search engines aren&#8217;t likely to do it too well either, I would think.</p>
<h4 id="toc-but-they-may-use-manual-checks-for-better-results-that-would-be-good-for-legitimate-use-of-this-technique">But they may use manual checks for better results; that would be good for legitimate use of this technique</h4>
<p>However, while automation and throwing lots of servers at a problem may seem problematic (for now!), these things require human, subjective, interpretation. So why not have people check sites manually?</p>
<p>Google, for example, does have a little army of people to manually verify sites are not using unfair tricks. So I guess if they are concerned about this particular technique, they might be able to get software to go a certain distance and then flag up suspicious cases to be manually checked. Legitimate sites should then be okay.</p>
<h4 id="toc-more-information1">More information</h4>
<p>But don&#8217;t take this as advice! Search engines often change the way they work! So check out this article from SEOMoz, a prominent SEO web site: <a href="http://www.seomoz.org/blog/guide-to-hidden-text">A Comprehensive Guide to Hidden Text &amp; Search Engines</a> (10 July, 2007).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onenaught.com/posts/35/hiding-content-on-web-pages-for-accessibility/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
