September 27, 201213 yr Sorry if this is a really silly question! If I wanted to italicise part of a paragraph, using css instead of the old <font tag, can I do it? Surely I just can't wrap a div class around one word inside a paragraph?
September 27, 201213 yr Author OK, a bit more googling found that apparently <em>, <u>, <strong>, <b>, <i> tags are still valid XHTML. But I was thinking of styling it a bit more than that. Can I set anywhere that bold would also change colour to white or anything? (Most text is off-white grey so I though bold and bright white would stand out nicely)
September 27, 201213 yr <p>This is normal text <em>this is italic by default in most browsers</em> <span class="italic">this is italic colored</span> text</p> CSS .italic { font-style: italic; color: #ffff00; } Read this http://html5doctor.com/i-b-em-strong-element/ Edited September 27, 201213 yr by Wickham
September 27, 201213 yr <em> is the proper and semantic way of doing things as it stands for "Emphasise". You can then apply any CSS to this, say it's in a paragraph with a class of 'pclass1' it would be styled like so... .pclass1 em { color:#fffff; } Edited September 27, 201213 yr by MikeChipshop Beaten by super quick fast Wickham!
September 27, 201213 yr Author That's fantastic, Many Thanks! So I guess a simple italic could use <i> and any text that I wanted to 'emphasise' in whatever way was my chosen style would use <em>
September 27, 201213 yr Author Do I need .pclass1 or can I specify this by itself as em if I want it to be used anywhere?
September 27, 201213 yr Author Forget that! I've just tried and found I can. Just what I was looking to do and very informatively answered, many thanks guys!
September 27, 201213 yr Use <em>...</em> by itself if you just want italic or combine it with a class if you want color or underline or want to change italic back to normal .pclass1 { color:#fffff; } <p><em class="pclass1">..............</em></p> You've got lots of alternatives. Note that Mike's .pclass1 em {} requires the class in an element preceding the em tag while my .pclass1 {} has to be inside the <em> tag. Edited September 27, 201213 yr by Wickham
September 27, 201213 yr By default in all browsers <em> will italicise text without any other styling being applied by yourself. My 'pclass1' class was just an example of how to style the <em> tag if you needed to.
Create an account or sign in to comment