this is some code myVariable = value don't forget that value should be ... do something with myVariableHere the
don't forget that value should be ...comment is to help you re-use this snippet but is useless in the code itself. So the snippet must be selectable for copy-paste EXCEPT these comments (try it ).
The comment is made non-selectable by the CSS property :
user-select: none;
Selector | Usage | Notes |
---|---|---|
div, p | select every <div> element and every <p> element |
This is actually a list of elements to select. |
div p | select every <p> element inside a <div> element |
<p></p> not selected <div> <p></p> selected <p></p> selected </div> |
div > p | select every <p> element that is the direct child of a <div> element |
<p></p> not selected <div> <p></p> selected <p></p> selected <notADiv> <p></p> not selected </notADiv> </div> |
div + p | select every <p> element that is placed immediately after a <div> element |
<p></p> not selected <div> <p></p> not selected </div> <p></p> selected <p></p> not selected |
div ~ p | select every <p> element that is preceded by a <div> element and having the same parent |
<p></p> not selected <div> <p></p> not selected </div> <p></p> selected <p></p> selected |
li:first-child | select the element that is the first child of its enclosing element (i.e. parent) |
<ul> <li></li> selected <li></li> not selected <li></li> not selected </ul> |
newline
' to Unix-style newlines :,;:{}()>+
' :Noticed the text + icon on the left ?
This text is not selectable, and not found in the HTML source code<p class="impatients">Noticed the text + icon on the left ?</p>
.impatients:before { content : 'For the impatients :'; color : #dd0044; text-decoration : underline; margin-right : 0.3em; text-shadow : 0 0 0.1em #f08; } .impatients:after { content : url('./pictures/lightning.png'); float : left; }
Since there can be only one content property per CSS class, the trick is to add the text via the :before
pseudo-class, and the icon with the :after
pseudo-class. Then, the icon is "moved" to the left thanks to the float : left;
.
<table>
required) to display contents on 2 columns :
<div class="column50percent">Left column</div> <div class="column50percent">Right column</div>
div.column50percent { width:50%; display:inline; float:left; }
This method is fine until columns are shown using background-color or border : they may not have all the same height
<div class="column50percent">Left column</div> <div class="column50percent">Right column</div>
div.column50percent { display:table-cell; width:49%; }
<div class="containing"> <div>start of columned content ...</div> <div>... columned content continued</div> </div>
div.container { column-count:2; }
Good practices recommend using proportional font-sizes such as em and % to let readers increase / decrease the font size smoothly without breaking the page layout. em's are multipliers of the document's base font size, which is often defaulted to font-size:16px;
by graphic user agents. So we have : 1em = 16px, which is fair but not really convenient.
Here comes a little hack : setting the default font size to 62.5% of its original value makes 1em = 10 px. To specify this in a CSS file, just do :
When it comes to relative lengths, you can also use CSS3's rem (source).