CSS: Root-based URLs

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
jayaitch
Rank II - Novice
Posts: 20
Joined: Fri Mar 30, 2012 3:14 pm

CSS: Root-based URLs

Post by jayaitch »

Hi,

testing a site in Batch Wizard with URL target I get this error on a CSS stylesheet:
This part of the property value is invalid: "url(/site1/gif/grearr.gif)". It should be removed or corrected.
list-style:circle outside url(/site1/gif/grearr.gif);
The actual definition:

Code: Select all

ul {
	list-style:circle outside url(/site1/gif/grearr.gif);
}
This, however, passes:

Code: Select all

.main a[href ^="www"] {
	background:url(/site1/gif/extlink.gif) center right no-repeat;
}
Testing the stylesheet in the CSE editor, the former gets the same error, while the latter is reported just as broken link (logically, it is a root-based URL, and the editor does not know about document root), with the path appended to the path to the stylesheet.

W3 validator has none complaints, neither as snippets nor loading the whole file via URL.

Searches on the web (i.a. Mozilla Dev & Stackoverflow) were not quite conclusive in that they usually refer to either relative (../etc) or absolute (http://etc), but not root-based (/etc) URLs.

I quite understand that relative URLs are relative to the location of the stylesheet. What I can't find is something definite on root-based URLs: root = document root of the web server, or root = location of the stylesheet (again)? For this question I am not caring that it works alright in browsers (Firefox, Vivaldi), I want a clear understanding.

This is with CSE 17.05. I delay updating to 18 as we are considering our options for a complete move to Linux (and I do not mean running major productivity programs in compatibility/emulator layers like Wine).

TIA

jayaitch
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: CSS: Root-based URLs

Post by Albert Wiersch »

Hello,

Sorry about that. I could not reproduce this in the current version (2018/v18) but was able to reproduce the error in v17.05 so it looks like a bug in v17.05 when checking "list-style".

Unfortunately bug fixes are limited to 2018/v18 right now because 2019/v19 is in development and it is impractical to fix versions before 2018/v18. Please just ignore the error or you can disable that message by making it appear in the Results Window in the editor and then right-clicking on it and choosing Message Options->Disable using Exact Text Match. Another option would be to upgrade to 2018/v18. If you find any bugs in v18 then in most cases they can still be fixed.

If a URL begins with "/" then it's a root relative URL so it's relative to the root directory which, if I understand your question correctly, would be the document root of the web server. This page may be helpful here:
http://ifyoucodeittheywill.com/2009/03/ ... tive-urls/

As for switching to Linux, I wish there was a native Linux version but CSS HTML Validator is a Windows exclusive. :D

I hope this helps. Please let me know if you have any more questions.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
jayaitch
Rank II - Novice
Posts: 20
Joined: Fri Mar 30, 2012 3:14 pm

Re: CSS: Root-based URLs

Post by jayaitch »

Hello Albert,

thanks for the confirmation. Glad it has been fixed already. It's easily enough ignored in the reports, only the lack of concise information had worried me, and that stylesheet approach of taking things relative to itself. So my understanding of root-based (or relative) was correct yet. (I had come about the linked page, too.)

There seems to be another bug regarding <frameset> with <onload> attribute, reporting this as not allowed. However, the specs at W3 say it indeed goes with <body> and <frameset>. No big deal and with frames deprecated anyway likely not worth any trouble. It is used here in one particular page to have a sitemap in the <noframes> section for the bots, while human users get the frontpage. And probably the bots have become smart enough nowadays, turning that page into a relic...

Yeah, switching to Linux would be a lot easier if one could start from scratch, without having to worry about limited to zero compatibility issues. Besides, I have not yet seen an HTML editor in the Homesite/Topstyle league for Linux.

Regards,

JayAitch
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: CSS: Root-based URLs

Post by Albert Wiersch »

Hello,

You're welcome!

Thanks for reporting that other bug with the "onload" attribute and the "frameset" element. That just required a "painless" change to the config file so it was easy to fix. You can download the updated config file for v17.05 here:
https://www.htmlvalidator.com/downloads ... 170cfg.zip

Please see the "readme" file in the above ZIP file for installation instructions.

NOTE: Do not use this config file for versions other than v17.04 or v17.05.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
jayaitch
Rank II - Novice
Posts: 20
Joined: Fri Mar 30, 2012 3:14 pm

Re: CSS: Root-based URLs

Post by jayaitch »

Many thanks, Albert. That was real fast! If only all our bugs and little enhancements would be so simple...Never dug into the config editor and did not even think of it now.

As an aside: how do you determine valid font names and is there a setting, too? There is a warning about "DejaVu Serif" referenced in a font definition here (enclosed in quotes allright):
The following typeface was not recognized (check spelling): "DejaVu Serif".
It is installed on this Windows machine, and I understand it is widely used (or at least installed) in the Linux world, thus not exactly exotic. Of course there are far too many fonts, even just for the ever evolving/increasing number of fonts coming with each OS version, to track them all, so I guess a more generic approach is at work.

Best regards,

JayAitch
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: CSS: Root-based URLs

Post by Albert Wiersch »

jayaitch wrote: Fri Sep 21, 2018 5:54 am Many thanks, Albert. That was real fast! If only all our bugs and little enhancements would be so simple...Never dug into the config editor and did not even think of it now.
Yep, it is great when something is simple. :D
jayaitch wrote: Fri Sep 21, 2018 5:54 amAs an aside: how do you determine valid font names and is there a setting, too? There is a warning about "DejaVu Serif" referenced in a font definition here (enclosed in quotes allright):
The following typeface was not recognized (check spelling): "DejaVu Serif".
It is installed on this Windows machine, and I understand it is widely used (or at least installed) in the Linux world, thus not exactly exotic. Of course there are far too many fonts, even just for the ever evolving/increasing number of fonts coming with each OS version, to track them all, so I guess a more generic approach is at work.
There's actually a long list of font names in CSS HTML Validator. However, sometimes I wonder if it's worth trying to keep up with all the font names and if this message and others like it are more confusing than helpful. Do you have an opinion on this? Should CSS HTML Validator just accept all font names or warn the user of ones that it doesn't recognize in hopes that it is actually pointing out a font name that is incorrect or misspelled? It would be easier not to check font names but I don't want to remove that functionality if it causes a reduction in the program's helpfulness.

As for "DejaVu Serif", I will add it to the list of recognized fonts. You can disable the messages that warn about unrecognized fonts if you are sure the font name is correct (be sure to disable by 'exact text match' so you are only disabling the message for that specific font name).
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
jayaitch
Rank II - Novice
Posts: 20
Joined: Fri Mar 30, 2012 3:14 pm

Re: CSS: Root-based URLs

Post by jayaitch »

Albert,

I suppose it is one of those things once started in good cheer, only to grow and grow to a point where it requires too much care to keep it up-to-date, yet is too advanced to just drop it.

Although I was just going for the errors in this batch check, I noticed a warning about a misspelled instance of "Ariel". Turned out it had propagated to a couple of other definitions. So while probably not a big deal given that it is just a run off the mill sans-serif, I am glad CSS HTML Validator found it.

Same with DejaVu Serif. It's part of a small serif font stack here, aiming at setting a reasonable default serif font for Windows, MacOS and Linux systems. It likely is hopelessly out of date and time, but as Validator drew my attention to it, I might as well update it in a spare minute.

So in one case it was good CSS HTML Validator knew the font, while in the other it might even have been helpful that it didn't! ;) OTOH it is an extra warning to check. (The fine-grained control over warnings is a great thing, too, but can also grow over one's head, and, what's worse, get unwieldy like a stylesheet of an old site, difficult to maintain and even more difficult to debug.)

DejaVu is, of course, a whole family with serif, sans, sansmono, condensed variants. So are other fonts coming to my mind like Liberation or Linux Libertine. I see that Ubuntu has its own default font family, named, right, Ubuntu. Where should one start, where stop?

Generally I would say it is good functionality, and albeit not very conspicious functionality which makes Validator stand out from the free online checkers. Typos aren't easily spotted nor necessarily noticed in this part. However, I also think the effort should be limited to the most common fonts, that is those shipping with the major operating systems/distributions, being the ones one can expect to work for almost all users. And I suppose even that is quite a lot and a lot of work. As for the plethora of downloaded webfonts--well, leave it to the web developer to see if the spelling is correct (and to disable the message if so he prefers).

As for myself, when I include a webfont, one way or other, I make sure it works. And as I download it, it is more or less platform-agnostic. But I won't--and can't--test all the platform-specific fallback fonts. While the generic serif/sans-serif should indeed be the ultimate resort, but if possible not for a typo living on for years!

Just found this site: http://www.fontreach.com/ It's fun to see what the top million websites use as first choice fonts, although in designing a website I'd rather know what fonts most users most likely will have on their machines, so that I might know how the precious design falls apart if a user does not get my fancy webfont. (DejaVu, Linux Libertine, Liberation, Gentium all rank really low, but then it may be just as well because the sites either use standard Windows fonts or a webfont as first choice in their font stacks...)

Best regards,

JayAitch
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: CSS: Root-based URLs

Post by Albert Wiersch »

Thanks for the feedback. I'll leave it in for now and continually update the list when needed. I have a script that grabs the fonts available from Google and I program those into CSS HTML Validator... so it's easy to add font names that way but of course not all fonts are listed there (but I bet a lot of the ones that are used on websites are).

I will see if I can take a look at the link you provided and its list of top fonts and make sure CSS HTML Validator recognizes all of them. Hopefully it already does so it won't be too much work but we'll see. :)
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
jayaitch
Rank II - Novice
Posts: 20
Joined: Fri Mar 30, 2012 3:14 pm

Re: CSS: Root-based URLs

Post by jayaitch »

After posting I thought there should be an API for Google fonts, providing a list of available font names. Suppose it could even auto-update at runtime. But then there likely would be trouble with the EU's Global Data Protectorate Regulation (GDPR)...

Best regards,

JayAitch
Post Reply