I tried to validate my site and i get this following error
there is no attribute «property»
<meta property="og:title" content="Free Sms" />
there is no attribute «allowTransparency»
…w:hidden; width:450px; height:21px;" allowTransparency="true">Facebook</iframe>
there is no attribute «placeholder»
…"search" type="text" placeholder="SEARCH" value="" class="searchInp …
First my code has this and i get 13 errors.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Changing the code to this reduce my error. but I get the 3 errors.Why? Any guide how to fix this?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="https://www.facebook.com/2008/fbml"
xml:lang="en" lang="en">
Complete
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="https://www.facebook.com/2008/fbml"
xml:lang="en" lang="en">
<head>
<title>Welcome to mysite</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="keywords" content="Social, Programming" />
<meta name="description" content="Share Ideas and become the best" />
<meta http-equiv="Content-Language" content="en" />
<meta name="robots" content="*" />
<meta name="document-type" content="text" />
<meta name="googlebot" content="NOODP" />
<meta name="slurp" content="NOYDIR" />
<meta name="msnbot" content="NOODP" />
<meta name="Generator" content="snippet" />
<meta property="og:title" content="Welcome to mysite" />
<meta property="og:type" content="website" />
<meta property="og:url" content="" />
<meta property="og:description" content="Share Ideas and become the best" />
<meta property="fb:app_id" content="" />
<meta property="og:image" content="http://mysite.com/images/fbicon.png" />
The attributes you mention are simply not part of XHTML 1.0 Transitional, so a validator has to report them as errors. Just remember that the concept of error is relative here: it means that the document does not conform to the document type definition it purports to comply with (by referring to a document type definition by the doctype
declaration).
The property
attribute is not part of HTML5 CR either, but validators like http://validator.nu use a “schema for HTML5 + SVG 1.1 + MathML 3.0 + RDFa Lite 1.1”, where the RDFa part allows property
.
If your markup is a mix of XHTML 1.0 Transitional and HTML5, for example, just relax. The mix works in browsers and other relevant software, except for validators, which need to be picky. Just use a doctype
that best corresponds to the markup you have, and manually check the error messages. If you get just 3 error messages when using XHTML 1.0 Transitional, keep using it, until you get fewer errors when checking against HTML5.
Comments
-
I tried to validate my site and i get this following error
there is no attribute «property»
<meta property="og:title" content="Free Sms" />
there is no attribute «allowTransparency»
…w:hidden; width:450px; height:21px;" allowTransparency="true">Facebook</iframe>
there is no attribute «placeholder»
…"search" type="text" placeholder="SEARCH" value="" class="searchInp …
First my code has this and i get 13 errors.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Changing the code to this reduce my error. but I get the 3 errors.Why? Any guide how to fix this?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
Complete
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml" xml:lang="en" lang="en"> <head> <title>Welcome to mysite</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta name="keywords" content="Social, Programming" /> <meta name="description" content="Share Ideas and become the best" /> <meta http-equiv="Content-Language" content="en" /> <meta name="robots" content="*" /> <meta name="document-type" content="text" /> <meta name="googlebot" content="NOODP" /> <meta name="slurp" content="NOYDIR" /> <meta name="msnbot" content="NOODP" /> <meta name="Generator" content="snippet" /> <meta property="og:title" content="Welcome to mysite" /> <meta property="og:type" content="website" /> <meta property="og:url" content="" /> <meta property="og:description" content="Share Ideas and become the best" /> <meta property="fb:app_id" content="" /> <meta property="og:image" content="http://mysite.com/images/fbicon.png" />
-
when i use doctype html5 i got lot of errors most of it are obsolete property.is it ok also to mixed it up? what happens to the tags or property that are obsolete in html5?
-
@Snippet, nothing happens to tags or attributes that are declared “obsolete” in HTML5. It’s just words, and HTML5 requires browsers to continue supporting “obsolete” features, and in any case they do so.
-
i see.thanks. How about my meta tags. when i change doctype to html5 some of my meta tags gat error like Bad value msnbot for attribute name on element meta: Keyword msnbot is not registered
-
@Snippet, similarly, it’s just about HTML5 requirements on documents (authors); they do not affect browsers or robots. The
meta
tags have their effects (usually none – mostmeta
tags are really write-only) quite independently of HTML5 restrictions on thename
andhttp-equiv
attributes. -
Thanks for everything.i haven’t change it to html five because of too many errors, using same doctype i have fixed the property error by changing to ‘name’ only the placeholder is now my problem
Recents
Related
The Facebook / Open Graph meta property attribute is not part of the HTML5 standard, so the W3C Markup Validator is correct in throwing up an error. In practice though, this incorrect attribute is harmless — social sites look for it and don’t care if it’s part of the standard or not. If you want to fix the W3C validator error, you’ll have to change the DOCTYPE of your website to XHTML+RDFa (an example follows). The DOCTYPE definition is usually located in the header.php
file of your theme.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
Facebook’s plugins use Open Graph, which is built on RDFa. It’s RDFa that adds the property
attribute to elements. Without this addition, plain HTML has no such attribute. (If you ask me, it’s a strange design to add a new attribute without namespacing it, and to re-use half of a <meta>
tag. But no-one did.)
To validate XHTML-with-RDFa, you’ll need the DOCTYPE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
This means you will have to be writing valid XHTML 1.1. More
One error that you might encounter when working with Python classes is:
AttributeError: 'X' object has no attribute 'Y'
This error usually occurs when you call a method or an attribute of an object. There are two possible reasons for this error:
- The method or attribute doesn’t exist in the class.
- The method or attribute isn’t a member of the class.
The following tutorial shows how to fix this error in both cases.
1. The method or attribute doesn’t exist in the class
Let’s say you code a class named Human
with the following definitions:
class Human:
def __init__(self, name):
self.name = name
def walk(self):
print("Walking")
Next, you created an object from this class and called the eat()
method:
person = Human("John")
person.eat()
You receive an error because the eat()
method is not defined in the class:
Traceback (most recent call last):
File "main.py", line 10, in <module>
person.eat()
AttributeError: 'Human' object has no attribute 'eat'
To fix this you need to define the eat()
method inside the class
as follows:
class Human:
def __init__(self, name):
self.name = name
def walk(self):
print("Walking")
def eat(self):
print("Eating")
person = Human("John")
person.eat() # Eating
Now Python can run the eat()
method and you won’t receive the error.
The same goes for attributes you want the class to have. Suppose you want to get the age
attribute from the person
object:
person = Human("John")
print(person.age) # ❌
The call to person.age
as shown above will cause an error because the Human
class doesn’t have the age
attribute.
You need to add the attribute into the class:
class Human:
age = 22
def __init__(self, name):
self.name = name
def walk(self):
print("Walking")
person = Human("John")
print(person.age) # 22
With the attribute defined inside the class, you resolved this error.
2. The method or attribute isn’t a member of the class
Suppose you have a class with the following indentations in Python:
class Human:
def __init__(self, name):
self.name = name
def walk():
print("Walking")
Next, you created a Human
object and call the walk()
method as follows:
person = Human("John")
person.walk() # ❌
You’ll receive an error as follows:
Traceback (most recent call last):
File "main.py", line 9, in <module>
person.walk()
AttributeError: 'Human' object has no attribute 'walk'
This error occurs because the walk()
method is defined outside of the Human
class block.
How do I know? Because you didn’t add any indent before defining the walk()
method.
In Python, indentations matter because they indicate a block of code, like curly brackets {}
in Java or JavaScript.
When you write a member of the class, you need to indent each line according to the class structure you want to create.
The indentations must be consistent, meaning if you use a space, each indent must be a space. The following example uses one space for indentations:
class Human:
def __init__(self, name):
self.name = name
def walk(self):
print("Walking")
This one uses two spaces for indentations:
class Human:
def __init__(self, name):
self.name = name
def walk(self):
print("Walking")
And this uses four spaces for indentations:
class Human:
def __init__(self, name):
self.name = name
def walk(self):
print("Walking")
When you incorrectly indent a function, as in not giving any indent to the walk()
method, then that method is defined outside of the class:
class Human:
def __init__(self, name):
self.name = name
def walk():
print("Walking")
# Valid
walk() # ✅
# Invalid
person = Human("John")
person.walk() # ❌
You need to appropriately indent the method to make it a member of the class. The same goes when you’re defining attributes for the class:
class Human:
age = 22
def __init__(self, name):
self.name = name
def walk(self):
print("Walking")
# Valid
person = Human("John")
person.walk() # ✅
print(person.age) # ✅
You need to pay careful attention to the indentations in your code to fix the error.
I hope this tutorial is helpful. Have fun coding! 😉