Welcome to WebmasterWorld Guest from 54.163.94.5

Forum Moderators: not2easy

Message Too Old, No Replies

css first-letter in firefox 3.6.10

css first-letter

     
11:43 pm on Sep 28, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 16, 2004
posts:946
votes: 0


I am using firewfox 3.6.10

code as follows

p:first-letter
{
font-size: 3em;
display: block;
float: left;
margin-right: 5px;
color: #000000;
}

When I refresh in browser it looks great do a refresh again and it reverts back to normal text and stays the same.

Any thoughts on this cant get it to work at all!

HELP
11:58 pm on Sept 28, 2010 (gmt 0)

Full Member

joined:July 31, 2005
posts: 272
votes: 0


The paragraph tags are already block level tags. an you also post the HTML and the browser being used?
9:14 am on Sept 29, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 16, 2004
posts:946
votes: 0


html is simply

<table width="600" class="fullh" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<p>Welcome</p>
</td>
</tr>
</table>
11:06 am on Sept 29, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 16, 2004
posts:946
votes: 0


I discovered the problem.

having the stlye in css inlclude file does not work but having it in the head section works fine

BUT WHY?
5:23 pm on Sept 29, 2010 (gmt 0)

Full Member

joined:July 31, 2005
posts: 272
votes: 0


By "css inlclude file", do you mean the external CSS file?

It WILL work in an external CSS file, but you have to be aware of the order of CSS precedence. You may have missed the fact that something was ignoring or restyling your style for the class/id.

Better to use this to select the paragraphs in the table cell as oppose to ALL paragraphs.


* { margin: 0; padding: 0; border: 0; }

table {
width: 600px;
margin: 0 auto; /* CENTERS TABLE */
}

table td p:first-letter {
font-size: 3em;
float: left;
margin-right: 5px;
color: #000;
}


"display: block;" is not needed as "p" tags are block level tags. The "float: left;" removed the content from the document flow. You might want to remove it as the text will be left by default unless re-styled to do otherwise.
8:57 pm on Sept 30, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 7, 2003
posts:4783
votes: 0



p:first-letter {
...
display: block;
...



The paragraph tags are already block level tags.


Actually while a <p> by default indeed is a block element, that's not true for p:first-letter : it's just the first letter, and hence inline by default.
Now floating it would be enough on it's own.

See also the example in [w3.org...] (using ::first-letter CSS3 syntax, but has plenty of examples).
10:19 pm on Sept 30, 2010 (gmt 0)

Full Member

joined:July 31, 2005
posts: 272
votes: 0


p:first letter; ONLY affect the first letter. There's no need to set it as a block level since the "p" IS already block level. Really is redundant.
2:08 pm on Oct 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 7, 2003
posts:4783
votes: 0


The <p> having block is mandatory: you can only use the first-letter pseudo class on block level elements.

But it's not because the <p> is a block level element that a part of it is that too! On the contrary most if not all children of a <p> will be -by default at least- inline elements.

Take a look at the CSS standard: [w3.org...] is shows a fictional syntax that explains how a browsr is to interpret first-letter and why you almost have to consider the first letter of a block element (as well as the first line) as separate children of the <p> that are generated on the fly by the browser.

The reason setting display block on the first letter isn't working (yet) is also simple: that a look at the second paragraph: browsers aren't supposed to let us do that.
3:07 pm on Oct 1, 2010 (gmt 0)

Full Member

joined:July 31, 2005
posts:272
votes: 0


It works fine for me without declaring the block level for the :first-letter. Even the w3c doesn't declare it a block level since the "p" tag already is one. Still redundant, but you all code your way. My example works perfectly for the first letter without declaring a block level for it.