This question already has answers here:
The reference to entity "foo" must end with the ';' delimiter
(2 answers)
Closed 6 years ago.
I am trying to include webfonts in the template of a Blogger blog:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
<link href='http://fonts.googleapis.com/css?family=Share:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Istok+Web:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
<b:if cond='data:blog.isMobile'>
<meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
<b:else/>
And when I try to save the template, I get:
Error parsing XML, line 5, column 76: The reference to entity "subset" must end with the ';' delimiter.
I tried to add a ; but unsuccessfully. The links are generated and taken from Google Web Font.
How should I solve this issue? Thanks.
That's because & is a reserved character in XML that means "an XML entity begins here". XML entities let you print characters or sequences of characters that are hard for you to embed in your document literally, either because you don't have it on your keyboard or because the document encoding forbids it. For instance, in (X)HTML, é prints the character "é", which is not easy to find on most US keyboard. (Available entities depend on the <!DOCTYPE> declaration of your XML document.)
The problem with that scheme is that it means you can't unambiguously leave literal & characters around your document if they can be the start of an entity, so you need to encode them as an entity to solve that problem.
You will need to replace all your stray & with &, which will print & without angering the XML parser. In your case, you should be good with replacing &subset= by &subset= in your two <link> tags.
Ampersands in XML indicate the start of an entity reference. It starts with an ampersand, then there's a marker indicating which entity it is referring to, then a semicolon to end it. In order to include a literal ampersand in a document, you need to use a character entity reference that refers to an ampersand, i.e. &.
As you have not done this, the parser is trying to parse the following data as if it were an entity reference, which it is not. That is why it fails to parse - it can't find the semi-colon at the end of the entity reference because it's not supposed to be an entity reference.
For instance, where you have:
http://fonts.googleapis.com/css?family=Share:400,700&subset=latin,latin-ext
You should have:
http://fonts.googleapis.com/css?family=Share:400,700&subset=latin,latin-ext
Related
In LaTeX, we can define a macro so that we don't have to keep typing the same thing all the time.
For my website, which is HTML + CSS, I'm constantly repeating a custom "separator": / .
Can I define a macro so that it expands to this string?
Surprised to have found nothing online about this. I guess it's because "macro" means a different thing in HTML?
You might use SGML entities, but it is not a standard compliant solution and it only works when serving the file as XHTML:
<?xml version="1.0"?>
<!DOCTYPE html [
<!ENTITY name "John">
<!ENTITY surname "Doe">
<!ENTITY fullname "&name; &surname;">
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Test</title></head>
<body>Hello, my name is &fullname;.</body>
</html>
As already noticed in other comments, use something else like JavaScript or XSLT.
Trying to learn to make a site. And right from the start:
How do I get HTML to display ščž and other various special characters like ł,ß,ö..?
You need to specify a character set so the browser knows what's being used in the page. For example, in your head section, try putting:-
<meta charset="UTF-8">
You can also try specifying symbols using their entity name/code, using the character reference table here - https://dev.w3.org/html5/html-author/charref
Here's an HTML5 example. meta declares the encoding of the HTML file. Make sure to save the file in that encoding!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>How do I get HTML to display ščž and other various special characters like ł,ß,ö,马..?</body>
</html>
You can enter any character you know the Unicode codepoint using &#xnnnn syntax. In the example above, U+9A6C is the Chinese character for horse(马).
Is there a concise way to scan an html script for entities it is unfamiliar with and import them with their html codes? All I'm getting in place of a 'degree celsius' character, for example, is a question mark.
I think your problem is that you're not declaring character encoding. What you need to do is this:
In your <head> element, insert the following code:
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
Reference from MDN
Reference from W3Schools
I am facing problem with html code validation. My code is like:
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body>
<!---this is a comment----->
</body>
</html>`
It shows me an error. The error code is :
Consecutive hyphens did not terminate a comment. -- is not permitted inside a comment, but e.g. - - is.
what was the problem in my comment?? Please help
When you have multiple dashes, this causes the HTML parser to think that the comment has ended, so it starts looking for a > which it cannot find.
So, when using comments, just use two dashed before and after, and never use two dashes in a row in the comment text itself.
This is formally not allowed, according to the specs:
4.7. Comments # T
Comments consist of the following parts, in exactly the following order:
the comment start delimiter "<!--"
text
the comment end delimiter "-->"
The text part of comments has the following restrictions:
must not start with a ">" character
must not start with the string "->"
must not contain the string "--"
must not end with a "-" character
The following is an example of a comment.
<!-- main content starts here -->
Your comment violates both the rules that I made bold.
Validators accept both form of tag <meta> and <meta/>. HTML5 specification says that no end tag should be present, hence the form of <meta><meta/> is prohibited. But I could not find any information about form <meta/>.
As per this HTML5 standard: http://www.w3.org/TR/html-markup/syntax.html#void-element
Start tags consist of the following parts, in exactly the following
order:
A "<" character.
The element’s tag name.
Optionally, one or more attributes, each of which must be preceded by one or more space characters.
Optionally, one or more space characters.
Optionally, a "/" character, which may be present only if the element is a void element.
A ">" character.
The meta is a void element and hence the part #5 would apply with a caveat that "optionally, a / character, which may be present..."
<meta ... />
And so, you may omit the part #5 i.e. the closing "/", and hence this is also valid:
<meta ... >
Further down the spec says:
Void elements only have a start tag; end tags must not be specified
for void elements.
To summarize, end tag is not required. Self closing is not required. It will not hurt if end tag or self-close is present.
.
It depends on whether you use HTML5 or XHTML5 syntax. In XHTML5 it is required and the parser will freak out if you don't use / when closing tag. Generaly all XML elements must have closing tag.
Try this snippet of code in Validator.nu
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document</title>
<meta charset="UTF-8"/>
</head>
<body>
</body>
</html>
Try to remove / from meta charset and observe the result. Don't forget to set correct preset for XHTML5.
Looking at Mozilla's documentation for it, as well as from what I've observed in general, you just don't close the tag.
<meta charset="utf-8">
The above is valid HTML5. There's no reason to include any sort of close tag or anything resembling a closing tag on it.