The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘HTML5’ Category

Web UI/UX & coding tip: if you have tabular data, display them using table/tr/th/td (via Victor on Twitter)

Posted by jpluimers on 2024/05/01

So true:

[Wayback/Archive] Victor on Twitter: “UI/UX & Coding Tip 💡 Do you need to display table data? Use tables. Yes, , and . Yes, it’s fine. No, you don’t need flex, grids, divs, and all that. Why? Because it’s a table 🤷‍♂️”

UI/UX & Coding Tip 💡

Do you need to display table data? Use tables.

Yes, <table>, <tr> and <td>.

Yes, it’s fine. No, you don’t need flex, grids, divs, and all that.

Why? Because it’s a table 🤷‍♂️

Read the rest of this entry »

Posted in Development, HTML, HTML5, Software Development, Web Development | Leave a Comment »

The W3C Markup Validation Service

Posted by jpluimers on 2024/04/03

A while ago I needed to validate some HTML on-line and found the W3C Markup Validation Service.

There are two versions of it that can take different parameters, so below are some permutations of the URLs.

But first why there are two versions, which is explained in W3C Markup Validation Service – Wikipedia

The Markup Validation Service is a validator by the World Wide Web Consortium (W3C) that allows Internet users to check pre-HTML5 HTML and XHTML documents for well-formed markup against a document type definition. Markup validation is an important step towards ensuring the technical quality of web pages. However, it is not a complete measure of web standards conformance. Though W3C validation is important for browser compatibility and site usability, it has not been confirmed what effect it has on search engine optimization.

As HTML5 has removed the use of DTD in favor of a “Living Standard”, the traditional Markup Validation Service is not applicable to these formats. Validation is instead performed using an open-source “Nu Validator”, an instance of which is provided by W3C.

Read the rest of this entry »

Posted in Development, HTML, HTML5, Software Development, Web Development | Leave a Comment »

Need to find a better way to log the essentials of a browser side HTML element using JavaScript object

Posted by jpluimers on 2023/12/04

The basic options for logging an HTML Element using JavaScript are for instance described in [Wayback/Archive] google chrome – How can I log an HTML element as a JavaScript object? – Stack Overflow (thanks [Wayback/Archive] Ben Flynn for asking and [Wayback/Archive] Mathias Bynens for answering)):

Use console.dir:
var element = document.documentElement; // or any other element
console.log(element); // logs the expandable <html>…</html>
console.dir(element); // logs the element’s properties and values

Both log all html or all properties even though often these are enough (most via [Wayback/Archive] Element – Web APIs | MDN):

Read the rest of this entry »

Posted in Development, HTML, HTML5, JavaScript/ECMAScript, Scripting, Software Development, Web Development | Leave a Comment »

javascript – Chrome debugging – break on next click event – Stack Overflow

Posted by jpluimers on 2023/11/23

I wish I had known this ages ago: [Wayback/Archive] javascript – Chrome debugging – break on next click event – Stack Overflow (thanks [Wayback/Archive] D.R. for asking and [Wayback/Archive] Konrad Dzwinel for answering):

What you are looking for are [Wayback/Archive] ‘Event Listener Breakpoints‘ on the Sources tab. These breakpoints are triggered whenever any event listener, that listens for chosen event, is fired. You will find them in the Sources tab. In your case, expand ‘Mouse’ category and choose ‘Click’.

Read the rest of this entry »

Posted in Chrome, Chrome, Development, Google, HTML, HTML5, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers, Web Development | Leave a Comment »

Javascript – Copy string to clipboard as text/html – Stack Overflow

Posted by jpluimers on 2023/09/27

For my link archive is the below answer that should help me a lot with unfinished bits from Some JavaScript bookmarklets for WordPress published pages centered around navigation and IDs.

Goal of that post was to have some grounding and eventually find a means to build an HTML page in a new tab using a bookmarklet that I then later could post to my blog.

Assembling to HTML and putting it on the clipboard might be a lot easier and better fitting in my workflow.

So, via [Wayback/Archivejavascript copy html to clipboard – Google Search, for my link archive: [Wayback/Archive] Javascript – Copy string to clipboard as text/html – Stack Overflow (thanks [Wayback/Archive] Loilo for answering and [Wayback/Archive] kofifus for asking):

Below is a function that will do exactly that. I tested it with your required browsers, it works in all of them. However, IE 11 will ask for confirmation on that action.

Explanation how this works can be found below, you may interactively test the function out in this jsFiddle.

Read the rest of this entry »

Posted in Chrome, Development, Firefox, HTML, HTML5, Internet Explorer, JavaScript/ECMAScript, JSFiddle, Power User, Scripting, Software Development, Web Browsers, Web Development | Leave a Comment »

Characters you need to escape in the Title of a WordPress post

Posted by jpluimers on 2023/07/18

I forgot to post this: [Wayback/Archive] Which characters need to be escaped in HTML? – Stack Overflow

If you’re inserting text content in your document in a location where text content is expected1you typically only need to escape the same characters as you would in XML. Inside of an element, this just includes the entity escape ampersand & and the element delimiter less-than and greater-than signs < >:
& becomes &amp;
< becomes &lt;
> becomes &gt;

I didn’t quote further, as this bit is somehow important for WordPress posts. WordPress reminded me the hard way when initially these posts were wrongly titled:

Warning:

It also means the “Press This” bookmarklet always gets unescaped plain text wrong. Watch this when selecting text for blogging and check if the selected text actually got into your post fine.

Thanks [Wayback/Archive] Ahmet for asking the above question and [Wayback/Archive] Jeremy for answering it.

–jeroen

Posted in Development, HTML, HTML5, SocialMedia, Software Development, Web Development, WordPress, WordPress | Leave a Comment »

Thanks Stephan Kämper for showing me how to validate HTML on-line at W3C

Posted by jpluimers on 2023/07/05

In Another difference between the and element in HTML&XHTML, I mentioned Stephan Kämper taught be about the W3C HTML NU validator in [Archive] Stephan Kämper on Twitter: “I try to write fairly simple & #valid #HTML ➙ …gist..Validating it with …online HTML-Validator…, I get the error ‘No p element in scope but a p end tag seen.‘ What? Why? Removing the list from the HTML, gets rid of the error… Why?!? I. don’t. get it. 1/2″ / Twitter.

Upon closer inspection, there are actually two w3c.org HTML validators, each operating in three modes:

  1. Default checker which is DTD-based:

    This validator checks the [Wayback/Archive] markup validity of Web documents in HTML, XHTML, SMIL, MathML, etc. If you wish to validate specific content such as [Wayback/Archive] RSS/Atom feeds or [Wayback/Archive] CSS stylesheets, [Wayback/Archive] MobileOK content (now retired), or to [Wayback/Archive] find broken links, there are [Wayback/Archive] other validators and tools available. As an alternative you can also try our [Wayback/Archive] non-DTD-based validator.

    1. [Wayback/Archive] The W3C Markup Validation Service: #validate_by_uri mode (without #validate_by_uri URL fragment) and

      default: checks the HTML of a URL

    2. [Archive] The W3C Markup Validation Service: #validate_by_upload mode

      you upload a file of which the HTML then gets checked

    3. [Archive] The W3C Markup Validation Service: #validate_by_input mode

      you enter the HTML to be checked into a text box

  2. NU checker which is non-DTD-based:
    1. [Wayback/Archive] Ready to check – Nu Html Checker; #address mode (without #address URL fragment) and

      default: checks the HTML of a URL

    2. [Archive] Ready to check – Nu Html Checker: #file mode

      you upload a file of which the HTML then gets checked

    3. [Archive] Ready to check – Nu Html Checker: #textarea mode

      you enter the HTML to be checked into a <textarea> element

Notes:

  1. that all three above modes get selected by a URL fragment (after a # hash) which the Wayback machine cannot individually save, but Archive.is can, hence the non-default URLs are not saved only in Archive.is, and not in the Wayback machine.
  2. The DTD-based checker seems non-functional and redirects all requests to the non-DTD-based checker.

I also took a look at the Wayback machine saved pages under the direct URLs of both checkers:

  1. https://web.archive.org/web/*/https://validator.w3.org/*
  2. https://web.archive.org/web/*/https://validator.w3.org/nu/*

I learned that the NU validator accepts at least these arguments:

Note that you cannot do this directly with HTML files saved in a gist or GitHub repository because it serves all RAW files as

[Wayback/Archive] text/plain MIME type. You can work around this by using a raw.githack.com trick I explained before at:

I also amended my above reply with more information using the ?doc= parameter with RAW gist files and archived that thread at [Wayback/Archive] Thread by @jpluimers on Thread Reader App – Thread Reader App.

–jeroen

Posted in Development, HTML, HTML5, Software Development, Web Development | Leave a Comment »

Another difference between the and element in HTML & XHTML

Posted by jpluimers on 2023/07/04

A few weeks after queueing What is the difference between <p>, <div> and <span> in HTML&XHTML?, Stephan Kämper posted an interesting other “TIL“.

Besides that TIL, it also taught me about an on-line HTML validator. Cool: I learned two things from Stephan that day!

The above post talked about phrasing versus non-phrasing elements, Stephan discovered another difference between the p and div elements:

Stephan’s TIL: [Archive] Stephan Kämper on Twitter: “TIL or Life (and the HTML specification) is full of wonders and surprises ➙ “List elements (in particular, ol and ul elements) cannot be children of p elements.” …” / Twitter

It was based on his quest [Archive] Stephan Kämper on Twitter: “I try to write fairly simple & #valid #HTML ➙ …gist..Validating it with …online HTML-Validator…, I get the error ‘No p element in scope but a p end tag seen.‘ What? Why? Removing the list from the HTML, gets rid of the error… Why?!? I. don’t. get it. 1/2″ / Twitter, which I archived at [Wayback/Archive] Thread by @S_2K on Thread Reader App – Thread Reader App.

I responded this: [Archive] Jeroen Wiert Pluimers on Twitter: “@S_2K I thought it would be something like explained in p/div/span differences But it is yet another html oddity where structural and logical concept are mixed in one language.” / Twitter.

Both his quest and tweet referred to this key documentation part: [Wayback/Archive] HTML Standard: grouping content; the p element; note on lists:

Read the rest of this entry »

Posted in Development, HTML, HTML5, Software Development, Web Development | 1 Comment »

Converting an inline svg image to file

Posted by jpluimers on 2023/06/28

Via [Wayback/Archive.is] inline svg to file – Google Search, found first [Wayback/Archive] Convert Inline SVG to File – Eyedeal Graphics

  1. Use your browser’s “View Source” or “Page Source” command to view the page’s HTML code.
  2. Locate and copy all the code between the beginning <svg> and closing </svg> tags.
  3. Paste the copied code, including the <svg> and </svg> tags into your text editor of choice. (Atom, Brackets, Visual Studio Code, Sublime Text, etc.)
  4. Save the text file as an SVG file. (ex. legacy-xyz-products-logo.svg)
  5. Open the SVG file in your preferred vector editing tool. (Adobe, Illustrator, Affinity Designer, Sketch, Inkscape, etc.)

That wasn’t enough, as not all SVG files then render properly, so luckily the next hit was [Wayback/Archive] html – Convert an inline SVG into a SVG file – Stack Overflow (thanks [Wayback/Archive] Paul LeBeau):

Read the rest of this entry »

Posted in Development, HTML, HTML5, Software Development, Web Development | Leave a Comment »

What is the difference between <p>, <div> and <span> in HTML&XHTML?

Posted by jpluimers on 2023/06/06

I write most of my documentation in Markdown or reStructuredText, so I don’t bump into html questions as often as in the past. But recently, I had to document in html as markdown was impossible, bumped in the choice between using div or p tags for paragraphs, and remembered there was a p problem not present with div but forgot which problem.

So I found [Wayback/Archive] What is the difference between <p>, <div> and <span> in HTML&XHTML? where the red bit explained what I forgot:

As others have answered… div and p are “block elements” (now redefined as Flow Content) and span is an “inline element” (Phrasing Content). Yes, you may change the default presentation of these elements, but there is a difference between “flow” versus “block”, and “phrasing” versus “inline”.

An element classified as flow content can only be used where flow content is expected, and an element classified as phrasing content can be used where phrasing content is expected. Since all phrasing content is flow content, a phrasing element can also be used anywhere flow content is expected. [Wayback/Archive] The specs provide more detailed info.

All phrasing elements, such as strong and em, can only contain other phrasing elements: you can’t put a table inside a cite for instance. Most flow content such as div and li can contain all types of flow content (as well as phrasing content), but there are a few exceptions: ppre, and th are examples of non-phrasing flow content (“block elements”) that can only contain phrasing content (“inline elements”). And of course there are the normal element restrictions such as dl and table only being allowed to contain certain elements.

While both div and p are non-phrasing flow content, the div can contain other flow content children (including more divs and ps). On the other hand, p may only contain phrasing content children. That means you can’t put a div inside a p, even though both are non-phrasing flow elements.

Now here’s the kicker. These semantic specifications are unrelated to how the element is displayed. Thus, if you have a div inside a span, you will get a validation error even if you have span {display: block;} and div {display: inline;} in your CSS.

Thanks [Wayback/Archive] Dhamu for asking that question and [Wayback/Archive] chharvey for explaining these details!

The [Wayback/Archive] HTML Standard: 3.2.5.2 Kinds of content has a cool diagram too:

Read the rest of this entry »

Posted in Development, HTML, HTML5, Software Development, Web Development | Leave a Comment »