Truncate text containing HTML, ignoring tags

Assuming you are using valid XHTML, it’s simple to parse the HTML and make sure tags are handled properly. You simply need to track which tags have been opened so far, and make sure to close them again “on your way out”. <?php header(‘Content-type: text/plain; charset=utf-8’); function printTruncated($maxLength, $html, $isUtf8=true) { $printedLength = 0; $position … Read more

What html markups to use for displaying label/value data?

I think the most semantically correct would be <dl>, <dt> and <dd>, since what you’re displaying are effectively definitions of first name, age and e-mail. <dl> <dt>First Name</dt> <dd>Dominic</dd> <dt>Age</dt> <dd>24</dd> <dt>E-mail</dt> <dd>foo@bar.com</dd> </dl> However, obviously, the easiest way to display it in a table is using <table>, <th> and <td>. You could hack together … Read more

Vertical dividers on horizontal UL menu

Quite and simple without any “having to specify the first element”. CSS is more powerful than most think (e.g. the first-child:before is great!). But this is by far the cleanest and most proper way to do this, at least in my opinion it is. #navigation ul { margin: 0; padding: 0; } #navigation ul li … Read more

Tool for testing Schema.org markup [closed]

This one came to my attention recently. linter.structured-data.org I like that it generates a preview when the Google Rich Snippet tool reports “Insufficient data to generate the preview.” The structured-data tool also generates a more structured, almost graphical result, which makes the results a bit easier to understand.

If YAML ain’t markup language, what is it?

Here’s the real story… 🙂 Clark, Oren and I started working on YAML in April 2001. Oren and Clark were part of the SML mailing list, which was trying to make XML simpler. I had just written a data serialization language for Perl called Data::Denter. Clark contacted me to tell me about an idea they … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)