<?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>CSS</title>
	<atom:link href="https://css.co.in/feed" rel="self" type="application/rss+xml" />
	<link>https://css.co.in</link>
	<description>Cascading Style Sheets</description>
	<lastBuildDate>Sat, 09 Jan 2021 15:49:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.6.2</generator>
	<item>
		<title>Mega Menu using CSS only</title>
		<link>https://css.co.in/mega-menu-using-css-only.html</link>
					<comments>https://css.co.in/mega-menu-using-css-only.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Sat, 09 Jan 2021 12:51:47 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<guid isPermaLink="false">http://css.co.in/?p=28</guid>

					<description><![CDATA[Demo : https://css.co.in/examples/mega-menu.html Code : https://gist.github.com/anjanesh/876b781b69fff9598fd73ffeda4b9318 Sorry for no explanation here. #top-menu-1 &#62; div &#62; a + div:hover has to be displayed as block too. For people who know CSS, I think most people just want to copy-paste code and edit for customization. And people who don&#8217;t know CSS will just edit the content.]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img src="https://i.imgur.com/gqVPbna.png" alt=""/></figure>



<p>Demo : <a rel="noreferrer noopener" href="https://css.co.in/examples/mega-menu.html" target="_blank">https://css.co.in/examples/mega-menu.html</a></p>



<p>Code : <a rel="noreferrer noopener" href="https://gist.github.com/anjanesh/876b781b69fff9598fd73ffeda4b9318" target="_blank">https://gist.github.com/anjanesh/876b781b69fff9598fd73ffeda4b9318</a></p>



<p>Sorry for no explanation here.</p>



<p><code>#top-menu-1 &gt; div &gt; a + div:hover</code> has to be displayed as block too.</p>



<p>For people who know CSS, I think most people just want to copy-paste code and edit for customization. And people who don&#8217;t know CSS will just edit the content.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/mega-menu-using-css-only.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using ::marker to display content before content</title>
		<link>https://css.co.in/using-marker-to-display-content-before-content.html</link>
					<comments>https://css.co.in/using-marker-to-display-content-before-content.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Sun, 01 Nov 2020 06:39:48 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[marker]]></category>
		<guid isPermaLink="false">http://css.co.in/?p=25</guid>

					<description><![CDATA[Ever wanted a piece of content before the content ? Well …. there is ::before which is what it is used for. But there is another selector called ::marker which is used for displaying content before a list item. It is possible to display a non-list item as an item via display: list-item; to a [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Ever wanted a piece of content before the content ?</p>



<p>Well …. there is <code>::before</code> which is what it is used for.</p>



<p>But there is another selector called <code>::marker</code> which is used for displaying content before a <em>list item</em>.</p>



<p>It <em>is</em> possible to display a non-list item as an item via <code>display: list-item;</code> to a div or p, so you don&#8217;t necessarily have to create a list like ul or ol.</p>



<p>According to <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/::marker">Mozilla</a>, <em>Only certain CSS properties can be used in a rule with ::marker as a selector</em> and one of them is <code>content</code> which can be used to insert custom content.</p>



<p>What is not possible is, to absolute position the content in the marker as it&#8217;s not supported till now. So for now, we have to do with the left alignment with the text.</p>


<pre class="brush: plain; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; &gt;
&lt;title&gt;Marker&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css&quot; crossorigin=&quot;anonymous&quot;/&gt;
&lt;style type=&quot;text/css&quot;&gt;
#div-marker
{
    width:500px;
    border:1px solid red;
}
#div-marker p
{
    display: list-item;
    margin-left:120px;    
}
#p-marker-1::marker
{
    content: &quot;marker content : &quot;;
}
#p-marker-2
{
    position: relative;
}
#p-marker-2::marker
{
    font-family: &quot;Font Awesome 5 Free&quot;;
    content: &quot;\f005&quot;;
    font-weight: 900;

    position:absolute; /* Won't work */
    top:25px; /* Won't work */
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

    &lt;div id=&quot;div-marker&quot;&gt;        
        &lt;p id=&quot;p-marker-1&quot;&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa, reprehenderit. Tenetur delectus repellendus eligendi fugit neque nulla adipisci tempora quam, error tempore repellat quibusdam esse officiis consequuntur vel nobis optio?&lt;/p&gt;
        &lt;p id=&quot;p-marker-2&quot;&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa, reprehenderit. Tenetur delectus repellendus eligendi fugit neque nulla adipisci tempora quam, error tempore repellat quibusdam esse officiis consequuntur vel nobis optio?&lt;/p&gt;
    &lt;/div&gt;    

&lt;/body&gt;
&lt;/html&gt;
</pre>


<figure class="wp-block-image size-large"><img loading="lazy" width="1020" height="506" src="https://css.co.in/wp-content/uploads/2020/11/marker.png" alt="" class="wp-image-26" srcset="https://css.co.in/wp-content/uploads/2020/11/marker.png 1020w, https://css.co.in/wp-content/uploads/2020/11/marker-300x149.png 300w, https://css.co.in/wp-content/uploads/2020/11/marker-768x381.png 768w" sizes="(max-width: 1020px) 100vw, 1020px" /></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/using-marker-to-display-content-before-content.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using the data URI scheme to reduce an HTTP request</title>
		<link>https://css.co.in/using-the-data-URI-scheme-to-reduce-an-HTTP-request.html</link>
					<comments>https://css.co.in/using-the-data-URI-scheme-to-reduce-an-HTTP-request.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Sat, 01 Jan 2011 04:08:50 +0000</pubDate>
				<guid isPermaLink="false">http://local.css.co.in/using-the-data-URI-scheme-to-reduce-an-HTTP-request.html</guid>

					<description><![CDATA[Ever wanted to include a 1px wide/high background image that repeats (one way), to your existing sprite image just to reduce that one HTTP request, even though it may not have that great an impact on speed ? Since the image repeats itself (repeat-x or repeat-y, not both-ways), embedding it to a sprite is only [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Ever wanted to include a 1px wide/high background image that repeats (one way), to your existing sprite image just to reduce that one HTTP request, even though it may not have that great an impact on speed ?</p>
<p>Since the image repeats itself (repeat-x <i>or</i> repeat-y, <i>not</i> both-ways), embedding it to a sprite is only useful if image&#8217;s width/height spans across the sprite image.<br />Using the <a href="http://en.wikipedia.org/wiki/Data_URI_scheme" target="_blank">data URI scheme</a>, its possible to embed an image into a <code class="css">background-image</code> property directly. This is supported by almost all browsers except IE7 and below. (Use <a href="http://www.greywyvern.com/code/php/binary2base64" target="_blank">this</a> to convert an image to base64 format)</p>
<p>This is normally not a good solution because the base64 encoded string of the image is more (1/3 more) in bytes than the image file itself. But for small images that, say, act as a backrgound image for a navigation container, its a good trade-off for that additional HTTP request.<br />And for IE6 &amp; IE7, use the image itself.</p>
<p><strong>style.css</strong></p>
<pre class="code"><code>.nav
{
    background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAiCAYAAACeLbMRAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oMHw4JJ8ytHAkAAAAhSURBVAjXY2DABYyMjP4zMTAwMFCJ+Pr1K4k6GBkZkbgApdoEsBPcDsAAAAAASUVORK5CYII%3D');
}</code></pre>
<p><strong>HTML page</strong></p>
<pre class="code"><code>&lt;!--[if lt IE 8]&gt;
&lt;link rel="stylesheet" type="text/css" href="ie67.css" /&gt;
&lt;![endif]--&gt;</code></pre>
<p><strong>ie67.css</strong></p>
<pre class="code"><code>.nav
{
    background-image:url(images/nav-bg.png);
}</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/using-the-data-URI-scheme-to-reduce-an-HTTP-request.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>FireFox Specific CSS</title>
		<link>https://css.co.in/firefox-specific-css.html</link>
					<comments>https://css.co.in/firefox-specific-css.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Sat, 04 Dec 2010 08:08:17 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Firefox]]></category>
		<guid isPermaLink="false">http://local.css.co.in/firefox-specific-css.html</guid>

					<description><![CDATA[Though the chances of wanting this is pretty slim, but if you want to target a set of CSS attributes just for FireFox instead of using JavaScript to alter the styles, its possible.Though most -moz- properties get deprecated &#38; later removed, when the official CSS3 one is implemented, the @-moz-document is Mozilla/Gecko-only specific which is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Though the chances of wanting this is pretty slim, but if you want to target a set of CSS attributes just for FireFox instead of using JavaScript to alter the styles, its possible.<br />Though most <i>-moz-</i> properties get deprecated &amp; later removed, when the official CSS3 one is implemented, the <a href="https://developer.mozilla.org/en/CSS/@-moz-document" target="_blank" style="color:#000;font-weight:bold">@-moz-document</a> is Mozilla/Gecko-only specific which is used to contain different styles rules based on filtering document URLs.</p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; /&gt;
&lt;title&gt;FireFox Specific CSS&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
h1
{
    color:red;
}
h2
{
    color:green;
}
@-moz-document url-prefix()
{
    h1
    {
        color:blue;
    }
    h2
    {
        color:black;
    }
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Hello&lt;/h1&gt;
&lt;h2&gt;World&lt;/h2&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>Example : <a href="http://css.co.in/examples/firefox-specific-css.html">Mozilla Extensions</a></p>
<h4>Related Links : </h4>
<ul class="related">
<li><a href="https://developer.mozilla.org/en/CSS_Reference/Mozilla_Extensions">Mozilla Extensions</a></li>
<li><a href="http://stackoverflow.com/questions/952861/targeting-only-firefox-with-css">Targeting only FireFox with CSS</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/firefox-specific-css.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Adjusting styles based on a language</title>
		<link>https://css.co.in/adjusting-styles-based-on-a-language.html</link>
					<comments>https://css.co.in/adjusting-styles-based-on-a-language.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Fri, 26 Nov 2010 16:40:14 +0000</pubDate>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[lang]]></category>
		<guid isPermaLink="false">http://local.css.co.in/?p=7</guid>

					<description><![CDATA[Traditionally, language HTML files would be stored separately and load language specific CSS files.But now we just store the language strings separately and programmatically print the language strings within the same HTML file.Very often I find myself adjusting the style attributes a little here and there for different languages just so that it fits nicely [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Traditionally, language HTML files would be stored separately and load language specific CSS files.<br />But now we just store the language <i>strings</i> separately and programmatically print the language strings within the same HTML file.<br />Very often I find myself adjusting the style attributes a little here and there for different languages just so that it fits nicely inside a container or a navigation bar and looks the same across all languages.<br />Its actually easy to set style attributes based on the language attribute, <b>lang</b> in the HTML element.</p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang="fr" dir="ltr"&gt;
&lt;head&gt;
&lt;meta charset="utf-8" /&gt;
&lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8" &gt;
&lt;style type="text/css"&gt;
html[lang="en"] h2
{
    color:black;
}

html[lang="hi"] h2
{
    color:red;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;The quick brown fox jumps over the lazy dog&lt;/h2&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p><a href="http://css.co.in/examples/language-fonts.html" target="_blank">This Example</a> doesn&#8217;t change the text colour using JavaScript. JavaScript was used to change the <b>lang</b> attribute value in the <b>html</b> element.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/adjusting-styles-based-on-a-language.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CSS only Tabs using :target</title>
		<link>https://css.co.in/css-only-tabs-using-target.html</link>
					<comments>https://css.co.in/css-only-tabs-using-target.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Fri, 15 Oct 2010 12:30:00 +0000</pubDate>
				<category><![CDATA[CSS3]]></category>
		<category><![CDATA[target]]></category>
		<guid isPermaLink="false">http://local.css.co.in/css-only-tabs-using-target.html</guid>

					<description><![CDATA[Its highly unlikely that tabs using only CSS would replace JavaScript based ones. &#60;!DOCTYPE html&#62; &#60;html lang=&#34;en&#34;&#62; &#60;head&#62; &#60;meta charset=&#34;utf-8&#34; /&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html;charset=utf-8&#34; &#62; &#60;title&#62;CSS Tabs&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; .css-tabs { position:relative; text-align:center; /* This is only if you want the tab items at the center */ } .css-tabs ul.menu { list-style-type:none; display:inline-block; /* Change [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Its highly unlikely that tabs using <i>only</i> CSS would replace JavaScript based ones.<br /><a href="http://css.co.in/examples/css-tabs.html#item-1" target="_blank"><img src="http://s3.css.co.in/img/tabs.png" alt="tabs" style="width:624px;height:71px;margin-top:15px"/></a></p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; &gt;
&lt;title&gt;CSS Tabs&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
.css-tabs
{
    position:relative;
    text-align:center; /* This is only if you want the tab items at the center */
}
.css-tabs ul.menu
{
    list-style-type:none;
    display:inline-block; /* Change this to block or inline for non-center alignment */
}
.css-tabs ul.menu &gt; li
{
    display:block;
    float:left;
}
.css-tabs ul.menu li &gt; a
{
    color:#000;
    text-decoration:none;
    display:block;
    text-align:center;
    border:1px solid #808080;
    padding:5px 10px 5px 10px;
    margin-right:5px;
    border-top-left-radius:5px; -moz-border-radius-topleft:4px; -webkit-border-top-left-radius:5px;
    border-top-right-radius:5px; -moz-border-radius-topright:4px; -webkit-border-top-right-radius:5px;
    -moz-user-select:none;
    cursor:pointer;
}
.css-tabs ul.menu li &gt; div
{
    display:none;
    position:absolute;
    width:100%;
    left:0;
    margin:-1px 0 0 0;
    z-index:-1;
    text-align:left;
    padding:0;
}
.css-tabs ul.menu li &gt; div &gt; p
{
    border:1px solid #808080;
    padding:10px;
    margin:0;
}
.css-tabs ul.menu li &gt; a:focus
{
    border-bottom:1px solid #fff;
}
.css-tabs ul.menu li:target &gt; a
{
    cursor:default;
    border-bottom:1px solid #fff;
}

.css-tabs ul.menu li:target &gt; div
{
    display:block;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;tab2&quot; class=&quot;css-tabs&quot;&gt;
    &lt;ul class=&quot;menu&quot;&gt;
    &lt;li id=&quot;item-1&quot;&gt;
        &lt;a href=&quot;#item-1&quot;&gt;Tab 1&lt;/a&gt;
        &lt;div&gt;&lt;p&gt;Tab Content 1&lt;/p&gt;&lt;/div&gt;
    &lt;/li&gt;
    &lt;li id=&quot;item-2&quot;&gt;
        &lt;a href=&quot;#item-2&quot;&gt;Tab 2&lt;/a&gt;
        &lt;div&gt;&lt;p&gt;Tab Content 2&lt;/p&gt;&lt;/div&gt;
    &lt;/li&gt;
    &lt;li id=&quot;item-3&quot;&gt;
        &lt;a href=&quot;#item-3&quot;&gt;Tab 3&lt;/a&gt;
        &lt;div&gt;&lt;p&gt;Tab Content 3&lt;/p&gt;&lt;/div&gt;
    &lt;/li&gt;
    &lt;li id=&quot;item-4&quot; title=&quot;click for Tab 4&quot;&gt;
        &lt;a href=&quot;#item-4&quot;&gt;Tab 4&lt;/a&gt;
        &lt;div&gt;&lt;p&gt;Tab Content 4&lt;/p&gt;&lt;/div&gt;
    &lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>I think its safe to say that its a real annoyance when the browser re-positions the page when a fragment (named anchor) link is clicked. We don&#8217;t want the page moving up on clicking on a tab button. <a href="http://css.co.in/examples/css-tabs.html#item-1" target="_blank">Example</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/css-only-tabs-using-target.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Preventing Images From Being Saved on Right-Click</title>
		<link>https://css.co.in/preventing-images-from-being-saved-on-right-click.html</link>
					<comments>https://css.co.in/preventing-images-from-being-saved-on-right-click.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Fri, 08 Oct 2010 01:09:08 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[images]]></category>
		<guid isPermaLink="false">http://local.css.co.in/preventing-images-from-being-saved-on-right-click.html</guid>

					<description><![CDATA[More often than not, people have asked that if they uploaded their profile picture online, would it be possible to disable downloading of their profile photo by others. There is no full-proof method of preventing images from being saved by the end user. The user can hit print-screen and crop the image out of the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>More often than not, people have asked that if they uploaded their profile picture online, would it be possible to disable downloading of their profile photo by others.</p>
<p>There is no full-proof method of preventing images from being saved by the end user.<br />
The user can hit print-screen and crop the image out of the screenshot, or can directly download the image by knowing the exact image URL from the page&#8217;s source code (HTML, CSS JavaScript) or using tools like FireBug, AdBlockPlus to extract the image URL.</p>
<p>Whats mentioned here is a simple common technique to prevent someone from saving the actual image by right-clicking on it &amp; <em>Save As</em> or <em>Get Image Location</em>.</p>
<ul>
<li>Set the image&#8217;s <strong>src</strong> attribute to a 1 pixel transparent gif</li>
<li>Set the image&#8217;s backgound-image property to the actual image you want it to show</li>
</ul>
<pre class="code"><code>&lt;img src="1x1.gif" alt="cat" style="background-image:url(cat.jpg)"/&gt;</code></pre>
<p><img style="width: 400px; height: 307px;" src="http://s3.css.co.in/img/no-save.jpg" alt="no save" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/preventing-images-from-being-saved-on-right-click.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>All Star Attributes for HTML5 elements in IE</title>
		<link>https://css.co.in/all-star-attributes-for-html5-elements-in-ie.html</link>
					<comments>https://css.co.in/all-star-attributes-for-html5-elements-in-ie.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Tue, 28 Sep 2010 13:07:43 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<guid isPermaLink="false">http://local.css.co.in/all-star-attributes-for-html5-elements-in-ie.html</guid>

					<description><![CDATA[It is very common to set margin:0 and padding:0 as default to all HTML elements via the star hack. * { margin:0; padding:0; } And we get so used to explicitly setting margins and paddings to elements that require them, that we assume no padding &#38; margins at all as default for all elements. With [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>It is very common to set <code class="css">margin:0</code> and <code class="css">padding:0</code> as default to all HTML elements via the <a href="http://css-tricks.com/margin-0-padding-0-no-longer-cool/" target="_blank">star hack</a>.</p>
<pre class="code"><code>* { margin:0; padding:0; }</code></pre>
<p>And we get so used to explicitly setting margins and paddings to elements that require them, that we assume no padding &amp; margins at all as default for all elements.</p>
<p>With <a href="http://html5shiv.googlecode.com" target="_blank">html5shiv</a> javascript, we can get most HTML5 functionality working in Internet Explorer (6,7,8). And with <a href="http://ie7-js.googlecode.com" target="_blank">ie7-js</a>, we can get IE (6,7,8) to behave more-or-less like IE9.<br />When using HTML5 elements such as <code class="html">header</code>, <code class="html">section</code>, <code class="html">footer</code>, <code class="html">aside</code>, <code class="html">nav</code>, <code class="html">article</code> &amp; <code class="html">figure</code>, the all star hack doesn&#8217;t work and hence we need to set them explicitly. (Looks like ie7-js is resetting the margins)</p>
<div>
<div class="left"><b>IE6 / IE7</b> : <br /><img src="http://s3.css.co.in/img/star-html5.IE7.jpg" alt="Screenshot in IE6 / IE7" style="width:200px;height:125px"></div>
<div class="left" style="margin-left:10px"><b>IE8</b> : <br /><img src="http://s3.css.co.in/img/star-html5.IE8.jpg" alt="Screenshot in IE8" style="width:200px;height:133px"></div>
<div class="clear"></div>
</div>
<p><code class="css">margin:0</code> isn&#8217;t applied in IE 6/7/8. So don&#8217;t forget to set it explicitly for HTML5 elements.</p>
<pre class="code"><code>header, section, footer, aside, nav, article, figure { display:block; <b>margin:0;</b> padding:0; }</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/all-star-attributes-for-html5-elements-in-ie.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Centering Lists</title>
		<link>https://css.co.in/centering-lists.html</link>
					<comments>https://css.co.in/centering-lists.html#respond</comments>
		
		<dc:creator><![CDATA[css]]></dc:creator>
		<pubDate>Tue, 18 May 2010 10:19:43 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[inline-block]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[nav]]></category>
		<guid isPermaLink="false">http://local.css.co.in/centering-lists.html</guid>

					<description><![CDATA[One of the most common techniques for creating a menu or some sort of a navigational bar is by using a list. A list is well-structured, uses fewer elements to parse than a table (buzzword tableless) and can always fall back to normal HTML when CSS or JavaScript is used to manipulate it for effects. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>One of the most common techniques for creating a menu or some sort of a navigational bar is by using a <a href="http://www.w3.org/TR/html401/struct/lists.html" target="_blank"><code class="html">list</code></a>. A <code class="html">list</code> is well-structured, uses fewer elements to parse than a table (buzzword <i>tableless</i>) and can always fall back to normal HTML when CSS or JavaScript is used to manipulate it for effects. (i.e, degrade gracefully)</p>
<p>This is probably the easiest way to center.</p>
<p class="center"><img src="http://s3.css.co.in/img/centering-lists-1.png" alt="" style="width:500px;height:39px"></p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; &gt;
&lt;title&gt;Centering Lists&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { margin:0; padding:0; }
#nav
{
    text-align:center; /* Not meant for centering a block element */
    padding:10px 0;
    background-color:lightblue;
}
#nav ul
{
    display:inline;
    padding:5px 0 5px 5px;
    background-color:green;
}
#nav ul li
{
    display:inline;
    background-color:yellow;
    margin-right:5px;
}
#nav ul li a
{
    display:inline;
    text-decoration:none;
    color:black;
    padding:0 5px;
}
#nav ul li a:hover
{
    background-color:red;
    color:white;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;nav&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;#&quot;&gt;Menu 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu 4&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;last&quot;&gt;&lt;a href=&quot;#&quot;&gt;Menu 5&lt;/a&gt;&lt;/li&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>But this has some drawbacks.</p>
<ul>
<li>
<h3>text-align</h3>
<p> is meant for aligning text, not block elements, but this works for centering <i>inline</i> blocks on all browsers. But now, all text nodes within all child blocks inherits this text-align alignment property.</li>
<li>
<h3>height</h3>
<p> Because the list and list items are inline, there is no room for adusting or specifying the height of the menu items. height, padding-top, padding-bottom won&#8217;t have any effect.</li>
</ul>
<p>A workaround for <i>inline</i> is by treating the list as a table and the list items as <code class="css">table-cells</code>. But Internet Explorer supports <code class="css">display:table</code> and <code class="css">display:table-cell</code> only from version 8 onwards. So this is a no no solution for IE 6 &amp; IE 7. See  <a href="http://www.quirksmode.org/css/display.html">the display declaration</a></p>
<p class="center"><img src="http://s3.css.co.in/img/centering-lists-2.png" alt="" style="width:500px;height:59px"></p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; &gt;
&lt;title&gt;Centering Lists&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { margin:0; padding:0; }
#nav
{
    padding:10px 0;
    background-color:lightblue;
}
#nav ul
{
    display:table;
    margin-left:auto;
    margin-right:auto;
    background-color:green;
}
#nav ul li
{
    display:table-cell;
    padding:10px 0 10px 5px;
    background-color:green;
}
#nav ul li.last
{
    padding-right:5px;
}

#nav ul li a
{
    text-decoration:none;
    color:black;
    padding:5px;
    background-color:yellow;
}
#nav ul li a:hover
{
    background-color:red;
    color:white;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;nav&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;#&quot;&gt;Menu 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu 4&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;last&quot;&gt;&lt;a href=&quot;#&quot;&gt;Menu 5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>A better option would be float the elements and specify exact widths. This works nicely when you know the exact content and can specify the width of each element.</p>
<p class="center"><img src="http://s3.css.co.in/img/centering-lists-3.png" alt="" style="width:500px;height:60px"></p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; &gt;
&lt;title&gt;Centering Lists&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { margin:0; padding:0; }
#nav
{
    padding:10px 0;
    background-color:lightblue;
}
#nav ul
{
    display:block;
    padding:5px 0 5px 5px;
    width:370px; /* 30x4 (width of a) + 125 (width of Menu Item 3) + 5x5 (margin right) + 5x10x2 (padding left &amp; right for a) */
    height:30px;
    margin-left:auto;
    margin-right:auto;
    background-color:green;
}
#nav ul li
{
    display:block;
    float:left;
    margin-right:5px;
    background-color:yellow;
}
#nav ul li a
{
    display:block;
    min-width:30px;
    width:30px;
    line-height:30px; /* Align vertically in the middle */
    text-align:center;
    text-decoration:none;
    color:black;
    padding:0 10px;
}
#nav ul li a:hover
{
    background-color:red;
    color:white;
}
&lt;/style&gt;
&lt;!--[if lte IE 7]&gt;
&lt;style type=&quot;text/css&quot;&gt;
#nav ul li.last
{
    margin-right:0;
}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;nav&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;#&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; style=&quot;width:125px;&quot;&gt;Menu Item 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;last&quot;&gt;&lt;a href=&quot;#&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>For a fully floating list with centering, applying <code class="css">display:inline-block</code> to the list is enough to achieve the desired result. But according to Quirksmode, <code class="css">inline-block</code> is incomplete in IE6 and IE7. I don&#8217;t know how incomplete works, but it wierdly seems to work in IE6 when added in <a href="http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx" target="_blank">IE conditional statements</a>.</p>
<pre class="code"><code>&lt;style type=&quot;text/css&quot;&gt;
#nav-container ul
{
    display:inline-block;
}
&lt;/style&gt;
&lt;!--[if lte IE 7]&gt;
&lt;style type=&quot;text/css&quot;&gt;
#nav-container ul
{
    display:inline; /* For some reason now this works as inline-block in IE6 ?!? */
}
&lt;/style&gt;
&lt;![endif]--&gt;
</code></pre>
<p>Full HTML :</p>
<p class="center"><img src="http://s3.css.co.in/img/centering-lists-4.png" alt="" style="width:500px;height:64px"></p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; &gt;
&lt;title&gt;Centering Lists&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { margin:0; padding:0; }
#nav
{
    text-align:center;
    padding:10px 0;
    background-color:lightblue;
}
#nav ul
{
    display:inline-block;
    padding:5px 0 5px 5px;
    background-color:green;
}
#nav ul li
{
    display:block;
    float:left;
    background-color:yellow;
    margin-right:5px;
}
#nav ul li a
{
    display:block;
    min-width:30px; /* Wont work in IE6 */
    line-height:30px; /* Align vertically in the middle */
    text-decoration:none;
    text-align:center;
    color:black;
    padding:0 10px;
}
#nav ul li a:hover
{
    background-color:red;
    color:white;
}
&lt;/style&gt;
&lt;!--[if lte IE 7]&gt;
&lt;style type=&quot;text/css&quot;&gt;
#nav ul
{
    display:inline; /* For some reason now this works as inline-block in IE6 ?!? */
}
#nav ul li.last
{
    margin-right:3px;
}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;nav&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;#&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu Item 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;last&quot;&gt;&lt;a href=&quot;#&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>And using HTML5&#8217;s <code class="html">nav</code> element :</p>
<pre class="code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot; &gt;
&lt;title&gt;Centering Lists&lt;/title&gt;
&lt;!--[if lt IE 9]&gt;
&lt;script src=&quot;http://html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { margin:0; padding:0; }
header, section, footer, aside, nav, article, figure { display:block; }
#nav
{
    margin-top:0; /* ie7-js's IE9.js seems to add a margin-top */
    text-align:center;
    padding:10px 0;
    background-color:lightblue;
}
#nav ul
{
    display:inline-block;
    padding:5px 0 5px 5px;
    background-color:green;
}
#nav ul li
{
    display:block;
    float:left;
    margin-right:5px;
    background-color:yellow;
}
#nav ul li a
{
    float:left; /* Required for IE6 */
    display:block;
    min-width:30px;
    line-height:30px; /* Align vertically in the middle */
    text-decoration:none;
    text-align:center;
    color:black;
    padding:0 10px;
}
#nav ul li a:hover
{
    background-color:red;
    color:white;
}
&lt;/style&gt;
&lt;!--[if lte IE 7]&gt;
&lt;style type=&quot;text/css&quot;&gt;
#nav ul
{
    display:inline; /* For some reason this works in IE6 ?!? */
}
#nav ul li.last
{
    margin-right:3px;
}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;nav id=&quot;nav&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;#&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu Item 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;last&quot;&gt;&lt;a href=&quot;#&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://css.co.in/centering-lists.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
