Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Creating Drop Caps in HTML and CSS
Old 06-19-2010, 09:43 AM Creating Drop Caps in HTML and CSS
Banned

Posts: 1
Name: hamza
Trades: 0
hello

A long time ago, it was very common practice in books and magazines for the style template to call for a Drop Cap. These days, many younger people might be scratching their head on what exactly a drop cap is. Well, a drop cap is a means to stylize a paragraph and to add a little splash and flavor to a page. The drop cap itself is usually the first letter of the first word of the first paragraph that is a much larger font and a different font type than the rest of the paragraph and spans the first few lines of the paragraph. It's a very simple means to add a bit of elegance to the page. The recommendation is to use drop caps for content sites that dedicate entire pages to a single article. It's not so much recommended for the front page or for pages with just a few paragraphs of content. The main intent for the drop cap is for content sites that are focused on articles.
There are few different methods you can use to create a drop cap. Way back in the day, to add a drop cap, you had to insert a graphic file. Web publishers would have to create a gif file of a single letter and then insert that into the paragraph. Times have changed and now publishers can use code to create the drop cap effect. Here's the first example on how to create a drop cap:
<span style="float:left;color:#D4D4C7;font-size:44px;line-height:35px;padding-top:3px; padding-right:3px;font-family: Times, serif, Georgia;">F</span>
Simply insert this code at the beginning of the first paragraph of your article. Of course, you can tweak it per your needs. The problem with this method is that it's a lot of code to have to insert for each and every article. Plus, it kind of junks up your HTML. A cleaner and simpler approach is to update your CSS. One possibility for updating your CSS to accommodate for drop caps is this:
p {
font-family: Arial, Helvetica, Sans-Serif;
font-size: 10pt;
color: #000000
}
p:first-letter {
font-family: Times, Times New Roman, Tahoma;
font-size: 36pt;
float: left;
}
The problem with this approach is that it creates a drop cap for every single paragraph on the page that begins with the <p> tag. This is not an ideal situation. A better approach is this: p.introduction:first-letter {
font-size : 300%;
font-weight : bold;
float : left;
width : 1em;
color : #c00;
}
This code works in Firefox, IE and Chrome and I'm sure it works in Safari as well but I didn't test that browser. In your HTML page, simply insert:
<p class="introduction">
around the first letter of the first paragraph on the page. For example: <p class="introduction">A</p><p> long time ago…</p>
You do need to use a new <p> tag after the <p class> tag, otherwise, you will lose your <p> formatting. While the above CSS code does work, I tweaked it a bit to look more aesthetically pleasing. p.introduction:first-letter {
font-size: 44px;
float: left;
color: #D4D4C7;
line-height: 35px;
padding-top: 3px;
padding-right: 3px;
font-family: Times, serif, Georgia;
}
You can experiment with what works best for your page, including changing the color, the font, the size and the padding.


Removed

Last edited by chrishirst; 06-19-2010 at 09:55 AM..
hamzatri is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-22-2010, 06:52 AM Re: Creating Drop Caps in HTML and CSS
Kelpie's Avatar
Skilled Talker

Posts: 82
Name: Andrew
Location: SW Scotland
Trades: 0
You would be able to this without needing the introduction class:

Code:
 
p:first-of-type:first-letter {
font-size: 44px;
float: left; 
color: #D4D4C7;
line-height: 35px;
padding-top: 3px; 
padding-right: 3px;
font-family: Times, serif, Georgia;
}
Unfortunately the first-of-type pseudoclass, being CSS3, isn't yet implemented even on on all up-to-date browsers. Yes IE8, that's YOU I'm talking about, dammit!
Kelpie is offline
Reply With Quote
View Public Profile
 
Old 06-22-2010, 09:58 AM Re: Creating Drop Caps in HTML and CSS
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Way back in the day, to add a drop cap, you had to insert a graphic file. Web publishers would have to create a gif file of a single letter and then insert that into the paragraph.
Not necessarily true, you could of also just increased the font size for the first letter giving it the same effect.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 06-22-2010, 03:17 PM Re: Creating Drop Caps in HTML and CSS
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Not really .. the effect would not be exactly the same.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 06-29-2010, 07:01 AM Re: Creating Drop Caps in HTML and CSS
marcus deli's Avatar
Skilled Talker

Posts: 72
Name: Marcus Deli
Trades: 0
However, getting the right alignment and spacing, as well as the standard problems with A and L. You can use a percentage font size to get the right sized letter, a line-spacing specified in terms of the new font size to get the vertical alignment.

You can try this code:
<style>
p {
font-family: Arial, Helvetica, Sans-Serif;
font-size: 10pt;
color: #000000;
}
p:first-letter {
font-family: Times, Times New Roman, Tahoma;
font-size: 36pt;
float: left;
}
</style>
marcus deli is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Creating Drop Caps in HTML and CSS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25565 seconds with 12 queries