PDA

View Full Version : PHP using xHTML, HELP


kirxklox
November 18th, 2007, 16:08
I have this problem:

<div id="{$button_element_id}" class="editBlock"> <span class="tinytext">Tags: <strong>Bold</strong> <em>Italics</em> <u>Underline</u> </span> </div>

<u> is undefined and will not validate. What can I use to make it do so? Can I use: <span class="u">

Dan
November 18th, 2007, 20:15
<u> has become deprecated, so yes, using a <span> is more appropriate.

kirxklox
November 18th, 2007, 20:20
I hope inimino will weigh in on the PHP of this. It seems wrong to me????

Dan
November 18th, 2007, 20:24
What's wrong with the PHP?

Using {$variable} is acceptable as long as it's within double-quotes, so you'd need to do something like

<?php echo "<div id=\"{$button_element_id}\" class=\"editBlock\"> <span class=\"tinytext\">Tags: <strong>Bold</strong> <em>Italics</em> <u>Underline</u> </span> </div>"; ?>

Your other option would be

<div id="<?php echo $button_element_id; ?>" class="editBlock"> <span class="tinytext">Tags: <strong>Bold</strong> <em>Italics</em> <u>Underline</u> </span> </div>

kirxklox
November 18th, 2007, 21:31
The output works the way it is written sincee we use a different means of PHP, we use an .htaccess hack;
<span class="tinytext">Tags: <strong>Bold</strong> <em>Italics</em> <u>Underline</u> </span>

This is the problem???

<span class="tinytext">Tags: <strong>Bold</strong> <em>Italics</em> <span class="und">Underline</span> </span>

The question is, can I do a span class inside a span class?

inimino
November 18th, 2007, 23:17
You can have a <span> inside a <span>, even with classes on both, yes.

However it is true that <u> is deprecated, so rather than replacing it with a span it is worth considering whether you can get away without it.

Is this for an authoring component in your CMS? In such cases an underline facility is not required for the same reasons that underlining is not used in print. If you provide bold and italics it is sufficient; underlining should be reserved for hyperlinks on the Web.

So, if I understand correctly what this is for, I would suggest using <b> and <i> alone.

<strong> and <em> should only be used in circumstances where you can expect them to be used for their intended semantics. Where they will be used for their presentation, as in a typical WYSIWYG editing component, or when presented as "bold" and "italic" buttons, you should use the corresponding <b> and <i> elements instead.

kirxklox
November 19th, 2007, 00:21
inimino: You are correct in that it is for the CMX System I am working on and the <u> tag is not really needed. I expect the <b> and the <i> tags to also become deprecated. That is why we have used the <em> and <strong> tags.

Do you agree?

kirxklox
November 19th, 2007, 01:31
Inimino: Thank you for the HELP. That allowed me to make the last 60 pages xHTML Valid.

inimino
November 19th, 2007, 03:18
You're welcome. I don't expect <b> and <i> to be deprecated, because of uses exactly like this. The current draft of HTML 5 makes <b> and <i> fully conforming.

Many people are familiar with print conventions (also adopted by desktop publishing) and expect the Web to follow them. To allow for authoring on the Web by such people it is most natural to use the <b> and <i> elements which have precisely the semantics people are familiar with from print.

kirxklox
November 19th, 2007, 03:19
You can see what I did HERE!

http://www.kirxklox.com/project/comments.php?id=2551