Linting HTML using CSS
bitsofco.de
bitsofco.de
FYI: SGML is way more powerful than XML, and its grammar formalism is identical to that of XML because XML was designed as a simplified subset of SGML. Though Relax NG, and also XML Schema, can theoretically express richer grammars than SGML, they can't be used for HTML due to lack of tag inference and other short syntax features, and the features that Relax NG has over SGML benefit data-oriented rather than document-oriented use cases (eg. the use cases that JSON and other serialization formats are arguably better suited for than markup in the first place IMO).
sgmljs.net can run (also) in the browser, so can also validate HTML5 in the browser.
Disclaimer: my project
head, meta, style, script, link { display: block; } a:not([href])
a[href="#"],
a[href=""],
a[href*="javascript:void(0)"] { … }
Wait, what should I use instead then?I believe Thief 1 and 2 have done this, but I may be wrong.
[0]: https://en.wikipedia.org/wiki/Pseudolocalization#Pseudolocal...
Source: somewhere in this video https://www.youtube.com/watch?v=E2MIpi8pIvY
You could also use JS and log the info to console. Last thing you want to do is this making its way into production and it probably will: sods law.
I just think the most efficient approach is to log violations to a console with exact line numbers.
npm install html-validator-cli -g
cd "$HOME"/Sites/mysite
html-validator --verbose --file=index.htmlhttps://www.w3.org/People/Raggett/tidy/
Search shows a few other options as well: https://duckduckgo.com/?q=html+linter&t=ftas&ia=web
Unless I'm misreading your question.
this kind of linting can't spot broken document structure
And telling everyone that every one of their images must have an alt tag is draconian. Sometimes an image is purely decorative. Sometimes an image doesn't convey any more than the paragraph beside it. Often an alt tag is written in a perfunctory way, or even when it isn't, it doesn't truly make things better for the blind person. I think they should be at the writer's discretion.
alt="(Decoration)" would clear it right up and only takes a few seconds.
As the article correctly states, an alt attribute should always be present; explicitly empty values signal that no alt content is needed for a screen reader.
An image without the alt attribute is not even valid HTML. Try it yourself: https://validator.w3.org/nu/#textarea
I think it's smart that alt is required. Many of us would otherwise blithely continue on without considering accessibility. (Sadly, most of us still do, and we build tools and abstractions that "automatically" set the alt to something, be it an empty string or the file name… defeating the purpose of inviting the author to explicitly create an alt content.)
Back to your comment - if you are of the habit of shitting on ideas just to provoke a defense of them in order to ultimately learn something, I suggest you find a more constructive approach to learning… you could have googled it for 15 seconds and could have instead written, “I thought making a rule of always including alt was dumb, but I googled it and discovered that it's required by the HTML standard because x, y, and z”
> You are spouting off a strong opinion that hasn't benefitted
> from any actual knowledge of the topic
> or from thinking about it for a more than a second.
I made my first website in the late '90s and have been doing web apps for a living for over a decade. I have thought about it quite a bit over the years, and I have been on both sides of the issue. > just to provoke a defense
I was not looking for a defense. I was trying to help others not feel guilty for not doing something that I think seldom makes a real difference. I'm thinking of most of the articles I have read, and I'm thinking of the difference to a screen reader in either case: (1) stopping to read some alt text or (2) simply silently skipping over it and just reading the article. In many cases I think it's best not to break the flow or waste the person's time. > An image without the alt attribute is not even valid HTML.
The spec says it is for a few cases (https://html.spec.whatwg.org/multipage/embedded-content.html...). But yes, for the case I'm thinking of it insists we explicitly put alt="". I think this is tedious and overstepping its bounds. If a writer doesn't want to put alt text for one of his images, he shouldn't have to. He chose to write an article instead of doing nothing.And I'm not really talking about being lazy. I'm talking about not wasting the reader's time. If you tell everyone it's better to put an alt tag than nothing at all, then you're going to get a lot of poorly written and annoyingly redundant alt text. If someone writes a text-based article, then it is handicap-accessible, with or without alt tags. What might be less accessible would be an article typeset with images (which is rare nowadays anyways) --- but even then, computers are so good now at deciphering images that even that might not be much of a problem either.
There is no "shitting on idea" in the parent comment (if you disagree, could you highlight what you mean by that?).
Also, "actively harmful"? What do you mean? He only nuanced the article message.