Why doesn't the list set to italic in div - css

I was wondering if anyone could tell me why doesn't the list set to Italic as a class in div?
<style type="text/css">
body{
font:62.5% Arial, Helvetica, sans-serif;
}
h1{
font:small-caps 1.6em "Times New Roman", Times, serif;
}
.recipe .intro{
font:italic 1em Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<h1>Recipes for Cheese</h1>
<p class="intro">Cheese is a remarkably versatile food, available in literally hundreds of varieties with different flavors and textures.</p>
<div class="recipe">
<h2>Welsh Rarebit</h2>
<p class="intro">Cheese is a remarkably versatile food, availalbe in literally hundreds of varieties with different flavors and textures.</p>
<ol>
<li>Lightly toast the bread</li>
<li>Place on a baking tray, and spread with butter.</li>
<li>Add the grated Cheddar cheese and 2 tablespoons of beer to a saucepan. Place the saucepan over a medium heat, and stir the cheese continuously until it has melted. Add a teaspoon of wholegrain mustard and grind in a little pepper. Keep stirring.</li>
<li>When thick and smooth, pour over each piece of taost spreading it to the edges to stop the toast from burning.</li>
<li>Place under the grill for a couple of minutes or until golden brown.</li>
</ol>
</div>
</body>
Isn't the order list should be italic since it's in class Recipe.
Please explain why it isn't.
Thanks

<li> doesnt inherit the properties of the css class .recipe, in order to apply it you have to do the following:
.recipe li{
font:italic 1em Arial, Helvetica, sans-serif;
}
Same happens with the tag <a>, you have to apply the value you need in the .css
You can check this demo
If you wanna get more info, check this documentation

Only .recipe .intro (your paragraph tag) has font:italic 1em Arial, Helvetica, sans-serif; applied. For all of .recipe to have that font, remove .intro.
.recipe .intro says: "for all elements that have the intro class that are decendants of all elements that have the recipe class, apply these styles."

Related

How can I set padding left in my template that works both for Outlook & Gmail Emails?

I set a padding left of 15 pixels in my code in my list element, the padding shown does not look the same in the two platforms.
<ul style="padding-left: 10px !important; margin: 0 !important;">
<li
style="text-align: left !important; font-size: 14px; font-family: bold, sans-serif, sans-serif !important;">
<span
style="color: #055151; line-height: 150%; font-family: bold, sans-serif;">List element</span>
</li>
</ul>
How to achieve this ?
The Outlooks on Windows use Word as a rendering engine for HTML and CSS. I see two things that could be problematic here:
Inline !important styles are not supported.
Word uses text-indent to actually position the list item marker. In order to avoid impacting other email clients, we can use mso-text-indent-alt that will apply specifically to the Outlooks using Word's rendering engine.
Here’s an example code that should match what you want to achieve:
<ul style="padding:0; margin:0 0 0 10px;">
<li style="mso-text-indent-alt:-0.75em; text-align:left; font:bold 14px sans-serif;">
<span style="color:#055151; line-height:150%;">List element</span>
</li>
</ul>
And here are test screenshots on Email on Acid.

What is the significance of the following CSS rule? li em { color: red; font-weight: bold; }

I'm not really good at computers but I must take learn programming, but anyways, I know what the rule does but I don't know what is significant about it. (I'm not native English speaker so not making things easier)
It sets the color of the text within the <em> tag (that is within <li> tag ) to red and it's font-weight to bold.
li em {
color: red;
font-weight: bold;
}
<ul>
<li>one <em>two</em> three</li>
</ul>
That is a rather significant rule, assuming that the list item wasn't already styled that way - in which case the selector is not significant because the <em> element will inherit these styles from the list item anyway.
li { color: red; font-weight: bold; }
<ul><li>one <em>two</em> three</li></ul>

CSS Font Bold - Inline

In CSS, how can I bold only the phone number so it will inline with the rest of the statement but the number is bold?
Instead of doing it in HTML as:
<div class="bubbleContent">› Start posting jobs today–
<strong> 01234 567 890</strong></div>
HTML:
<div class="content">› Call me – 01234 567 890</div>
CSS:
div.bubbleContent
{
font-size: 11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
margin-top: 15px;
}
Thanks.
You can use <span> as in example shown below:
HTML:
<div class="content">› Call me – <span class="highlight">01234 567 890</span></div>
CSS:
div.content
{
font-size: 11px;
font-family:Verdana, Arial, Helvetica, sans-serif;
margin-top: 15px;
}
span.highlight
{
font-weight:bold;
}
You can also use <div> element with property display:inline, so it will be inline with the rest of the text.
You can’t. You cannot style a piece of text in CSS without making it an element one way or another (unless it can be referred to as a pseudo-element, but this currently works for first letter and first line only).
There are many HTML elements that you could use (such as strong, b, span), but the point is that you need some element. You can use an element that is displayed in bold by default, or you can style it with CSS.
You could generate the element with JavaScript client-side, though. For this, you would need to specify the syntax of phone numbers to be recognized, making sure that only phone numbers will match it in the content that will be used.

Different font for list numbers and list contents

In CSS, I am trying to style an ordered list so that the contents are one font, but the the numbers are another font.
How can I target the list-numbers, which aren't html elements and part of the list-style ?
The only thing that I can think of and have tried is making the list an unordered list. Setting the list-style to none and then manually having numbers inside the list that are wrapped in 's where I style them differently.
But that seems highly inefficient.
HTML
<ol>
<li><p>Hello</p></li>
<li><p>World</p></li>
</ol>
CSS:
ol{
font: italic 1em Georgia, Times, serif;
}
ol p{
font: normal .8em Arial, Helvetica, sans-serif;
}
JSFiddle of the example above

How to align two columns of text in CSS

I'm having some trouble lining up some text. I need two columns, one with numbers and one with text, like so:
1 Entry one
2 Entry two
3 Entry three
4 Entry five
5 Entry six
The left column is Georgia and the right column is Arial (slightly different font sizes). I could have a container div for each row and absolutely position the number and text paragraphs to be at the top or bottom of these, which works fine. The problem is this means I have to give each row a fixed height so that it displays properly, which causes a problem if the text needs to flow onto more than one line (which it may well do as the text entries are dynamic).
I want to do this without using a table, and without using absolute positioning so that the individual text entries can span over more than one line (and is cross-browser compatible).
As per my comment, I think the best element for the job is an ordered list.
ol {
font-family: georgia, serif;
font-size: 16px;
font-weight: bold;
}
ol li span {
font-family: arial, sans-serif;
font-weight: normal;
font-size: 12px;
}
<ol>
<li><span>Entry one<br>text on another line</span></li>
<li><span>Entry two</span></li>
<li><span>Entry three</span></li>
<li><span>Entry five</span></li>
<li><span>Entry six</span></li>
</ol>
With the span to allow changing of font-family between the list "bullets" and the content within, these could be divs if you have block content.
You should just use an appropriately styled ol element, something like this:
See: http://jsfiddle.net/tPjQR/
If you want to have different styles on the number versus the list content, you'll need to wrap the content of each li in something like a span. There just isn't a better way.
ol {
font-family: Georgia, serif;
}
ol span {
font-family: Arial, sans-serif;
font-size: 17px
}
<ol>
<li><span>Entry one</span></li>
<li><span>Entry two</span></li>
<li><span>Entry three</span></li>
<li><span>Entry five</span></li>
<li><span>Entry six</span></li>
<li><span>Entry Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long</span></li>
</ol>

Resources