So I am just starting to use the classes portion of python and I’ve constructed a class and main program that my text book asked me to write. It looks ok to me but I keep getting an error saying that my class doesn’t have this specific attribute, which is weird because it should. Now this is just a simple Rectangle, find the perimeter and area program. So it is nothing too complicated. But maybe you guys can see something I cannot.
Here is what my class looks like:
class Rectangle:
def __init__(self, length = 1, width = 1):
self.length = length
self.width = width
def setWidth(self, width):
self.width = width
def setLength(self, length):
self.length = length
def getPerimeter(self):
return (2 * self.length) + (2 * self.width)
def getArea(self):
return self.length * self.width
Here is the actual main program
from Rectangle import Rectangle
recWidth = eval(input("Enter the length of the rectangle: "))
recLength = eval(input("Enter the width of the rectangle: "))
x = Rectangle()
y = Rectangle()
x.width(recWidth)
x.length(recLength)
print("The perimeter of a rectangle with a width of", recWidth,
" units and a length of ", recLength, " units is ", x.getPerimeter(), ".")
Thanks I hope I have provided enough information to help formulate a valid question.
Line25 is reader supported. At no cost to you a commission from sponsors may be earned when a purchase is made via links on the site. Learn more
Designers spend hours carefully crafting every little detail in the design of their website, but the quality of their coding often comes up short. For proof, just look at the sites showcased in CSS galleries, 90% will have validation errors – Most of which are easy and simple fixes. Let’s look at some of the most common validation errors that appear time and time again, and how to correct them to really finish off your sites with high-quality code.
Pin
If it looks OK in the browser, why bother validating? is a common response to validation. Remember that a website isn’t all about how it looks. An HTML page is made to present data, not visual graphics, so this data should be written correctly to ensure it’s readable by a wide spectrum of people who use the web. These people might not be browsing the same as you, instead of seeing the visual website you’ve designed in a browser, they might be hearing the site through a screen reader.
An error free HTML page is much more likely to be rendered correctly by a range of browsers, and maintain compatibility with future versions. Not to mention the search engine bots for all you SEO people – You wouldn’t want to put obstacles in their way, a clean and valid page is going to be much easier for the bots to read and scan.
There’s also the aspect of professionalism. I see invalid HTML little like spelling mistakes, although the client probably won’t see a mistake in your code, the idea is still the same. You wouldn’t want to supply a design full of typos or spelling errors, so you shouldn’t really settle for an HTML page full of little validation issues.
Here’s a bunch of validation errors that were picked out from sites showcased on the first page of a well known CSS gallery. Many of the sites looked great, but as you can see, the quality of code just doesn’t match the quality of the design. The thing is, all of these errors can be easily fixed in minutes.
No Doctype at all
Pin
The worst thing you could do validation wise is to forget a Doctype altogether! No Doctype means browsers will have to guess what language your page is written in. To fix this error and all the subsequent issues, add an HTML or XHTML doctype to your page.
Forgetting to close an element
Pin
If you’ve opened a tag somewhere in your HTML document, you must remember to close it in the appropriate place. Forgetting to do so won’t just invalidate your HTML, it might also be the cause of some serious layout problems. The warning for this in the W3C validator is the cryptic message end tag for “p” omitted, but OMITTAG NO was specified
– Which basically means Dude, you forget to close that paragraph tag
Missing / on self-closing elements
Pin
Most HTML elements have a separate closing tag, eg: </div>
, but other elements like input
, img
and meta
are self-closing, this means they have a trailing slash before their closing bracket. Forgetting this is just the same as forgetting a closing tag altogether.
Forgetting to convert special characters
Pin
The ampersand is probably the most popular offender here, along with quotation marks that have been pasted in from Word. Always remember to check through your body copy and convert any &
signs to the HTML entity &
, and all other special characters to their appropriate entity symbol.
Unencoded characters in URLs
Pin
Following on from the last point, special characters, particularly the ampersand should also be converted to entities when they appear in URLs. Links to sites built in PHP are likely to include variables in their links using the &
character, so write these in your HTML using the &
entity.
Block elements inside inline elements
Pin
A fundamental rule of HTML is that block elements should never go inside inline elements. A popular example is an anchor inside a header:<a href="#"><h3>bananas</h3></a>
The <h3>
is a block element, so it should wrap the anchor (an inline element) like so:<h3><a href="#">bananas</a></h3>
.
No ALT attribute added to images
Pin
Every image inserted into your HTML document should have an ALT attribute to describe its contents. If the image is for presentation purposes only the ALT attribute should still exist but may be left empty, eg: alt=""
. Otherwise a clear description of the image contents should be provided.
Using attributes like “width” and “height”
Pin
This is probably a side effect of using a WYSIWYG editor which tend to insert HTML that shouldn’t really be there. width
and height
attributes are perfectly fine in Transitional Doctypes, but if you’re aiming for perfection with a Strict Doctype you should know that presentational styling should be saved for the CSS stylesheet.
Starting a class or ID with a number
Pin
Class, ID or name attributes can’t begin with a number. They can include numbers, just not at the start of the word.
Pin
Unlike HTML, CSS is used just to display the visual aspect of a web page, therefore the statement “If it looks good in the browser, why bother validating?” stands to a certain degree. An invalid CSS document isn’t going to have as much affect as an invalid HTML document, but you should run a validation check just to make sure you haven’t made any typos or mistakes in your code. If you’ve used any fancy CSS3 properties, these will invalidate your document as they’re not yet part of the spec, as long as you know they’re correct they can be ignored.
Written by Iggy
Iggy is a designer who loves experimenting with new web design techniques, collating creative website designs, and writing about the latest design trends, inspiration, design freebies, and more. You can follow him on Twitter
Подскажите в чем ошибки кода?
Валидатор http://validator.w3.org
Доктайп XHTML 1.0 Transitional
С 1-6 ошибки в бегущей строке marquee.
1. there is no attribute «width» <marquee width=»1000″ height=»24″ direction=»left» scrollamount=»3″ style=»…
2. there is no attribute «height» <marquee width=»1000″ height=»24″ direction=»left» scrollamount=»3″ style=»…
3. there is no attribute «direction» …ee width=»1000″ height=»24″ direction=»left» scrollamount=»3″ style=»font: 18p…
4. there is no attribute «scrollamount» …ht=»24″ direction=»left» scrollamount=»3″ style=»font: 18px Verdana, Geneva, s…
5. there is no attribute «style» …rection=»left» scrollamount=»3″ style=»font: 18px Verdana, Geneva, sans-serif;…
6. element «marquee» undefined …le=»font: 18px Verdana, Geneva, sans-serif; color:#ffffff; font-weight: bold;»>
7. element «noindex» undefined <p><noindex><a href=»test.html» class=»mo»><!—<im…
8. element «noindex» undefined <noindex>
Плюсоните если помог…
- Remove From My Forums
-
Question
-
User651828378 posted
Hi.
I get 7 wierd validations error from w3c, i have trying to make em but with no luck, so now i hope that U can help me.
My doctype is:<?xml version=»1.0″ encoding=»iso-8859-1″?>
<!DOCTYPE html PUBLIC «-//W3C//DTD XHTML 1.0 Strict//EN»
«http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd»>
<html xml:lang=»da»>
<head>
<title>sitecopy.png</title>
<meta http-equiv=»Content-Type» content=’text/html; charset=»iso-8859-1″‘ />This page is not Valid XHTML 1.0 Strict!
Below are the results of checking this document for
XML well-formedness and validity.- Error Line 12 column 41:
there is no attribute «align»....le width="1000px" border="0px" align="center" cellpadding="0px" cellspacing="
MY LINE IS: <table width="1000px" border="0px" align="center" cellpadding="0px" cellspacing="0px">You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the «Strict» document type with a document that uses frames (e.g.
you must use the «Transitional» document type to get the «target» attribute), or by using vendor proprietary extensions such as «marginheight» (this is usually fixed by using CSS to achieve the desired effect instead).This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using
the <embed> element to incorporate flash media in a Web page, see the
FAQ item on valid flash.✉
- Error Line 16 column 18:
there is no attribute «name».<td><img name="freespace_r1_c1" src="images/freespace_r1_c1.png" width="162p
MY LINE IS: <td><img name="freespace_r1_c1" src="images/freespace_r1_c1.png" width="162px" height="88px" border="0px" id="freespace_r1_c1" alt="" /></td>"center" cellpadding="0px" cellspacing="
MY LINE IS: <table width="1000px" border="0px" align="center" cellpadding="0px" cellspacing="0px">You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the «Strict» document type with a document that uses frames (e.g.
you must use the «Transitional» document type to get the «target» attribute), or by using vendor proprietary extensions such as «marginheight» (this is usually fixed by using CSS to achieve the desired effect instead).This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using
the <embed> element to incorporate flash media in a Web page, see the
FAQ item on valid flash.✉
- Error Line 16 column 18:
there is no attribute «name».<td><img name="freespace_r1_c1" src="images/freespace_r1_c1.png" width="162p
MY LINE IS: <td><img name="freespace_r1_c1" src="images/freespace_r1_c1.png" width="162px">✉
- Error Line 16 column 104:
there is no attribute «border»...." width="162px" height="88px" border="0px" id="freespace_r1_c1" alt="" /></..
MY LINE IS: <td><img name="freespace_r1_c1" src="images/freespace_r1_c1.png" width="162px" height="88px" border="0px" id="freespace_r1_c1" alt="" /></td>✉
- Error Line 75 column 33:
there is no attribute «background».<td valign="top" background="images/whitespace_r4_c2.png" width="12px"></..
MY LINE IS: <td valign="top" background="images/whitespace_r4_c2.png" width="12px"></td>✉
- Error Line 75 column 69:
there is no attribute «width».... background="images/whitespace_r4_c2.png" width="12px"></td>
MY LINE IS: <td valign="top" background="images/whitespace_r4_c2.png" width="12px"></td>✉
- Error Line 81 column 31:
there is no attribute «height».<td width="361px" height="367px" bgcolor="#232323" valign="top">Vulputate
MY LINE IS: <td width="361px" height="367px" bgcolor="#232323" valign="top">✉
- Error Line 81 column 47:
there is no attribute «bgcolor»....width="361px" height="367px" bgcolor="#232323" valign="top">Vulputate consequ
MY LINE IS: <td width="361px" height="367px" bgcolor="#232323" valign="top">
- Error Line 12 column 41:
Answers
-
User-158764254 posted
when running in XHtml Strict mode, you should replace those attributes with their equivalent css
for example: bgcolor=»#232323″
becomes: style=»background-color: #232323;»-
Marked as answer by
Thursday, October 7, 2021 12:00 AM
-
Marked as answer by
-
User487807879 posted
Try with this:
style=»text-align:center;»
-
Marked as answer by
Anonymous
Thursday, October 7, 2021 12:00 AM
-
Marked as answer by
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
Using HTML Tranistional in the w3c I am getting several «there is no attribute». How can I change my html to remove this error from my w3c validation?
fberriman
Offline
Enthusiast
Reading, England, UK
Last seen: 16 years 15 weeks ago
Reading, England, UK
Joined: 2006-06-02
Posts: 146
Points: 0
there is no attribute
Can you maybe show us your output so we can see exactly which attributes are throwing up the errors?
thepineapplehead
Offline
Moderator
Last seen: 1 year 7 weeks ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819
there is no attribute
Verschwindende wrote:
- CSS doesn’t make pies
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
there is no attribute
The following output from w3c includes the following
Error there is no attribute «ONCONTEXTMENU»
<body oncontextmenu=»return false;»
Error there is no attribute «BGPROPERTIES».
bgproperties=» fixed»>
Error there is no attribute «SRC»
«Narration1″><embed src=»audio/na007198.mp3»
Error there is no attribute «AUTOSTART».
autostart=»True»
Error there is no attribute «WIDTH».
width=»0″
Error there is no attribute «HEIGHT».
height=»0″></span><script type=»Text/JavaScript»>
Please remember this is generated via legacy VB6.0 code and I need to find the fix and then update the VB to clean up the html output.
Attached is a sample html file. Any help would be greatly appreciated.
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
file attached
Attached is the html file. wink
gary.turner
Offline
Moderator
Dallas
Last seen: 2 years 14 weeks ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858
there is no attribute
«oncontextmenu» is a proprietary IE attribute and is not a part of html.
«bgproperties» is a proprietary IE attribute and is not a part of html.
All the attribute attached to <embed> are invalid, because embed is a proprietary netscape element and is not a part of html. Use the object tag.
The id, «SCOMenu» is used multiple times, not allowed. Make it a class, and you should be ok.
cheers,
gary
If your web page is as clever as you can make it, it’s probably too clever for you to debug or maintain.
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
onContextmenu and bgproperties
Please tell me what I should change this to so that it will pass w3c validation
body oncontextmenu=»return false;» bgproperties=fixed
The FAQ is very helpful as well.
Thank you,
Cyndi
!
roytheboy
Offline
Guru
North Wales, UK
Last seen: 9 years 46 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41
there is no attribute
As these are not standard HTML attributes then you’ll need to remove them.
Life’s a b*tch and then you die!
thepineapplehead
Offline
Moderator
Last seen: 1 year 7 weeks ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819
there is no attribute
For the bgproperties, put this in the css:
body {
background-position: fixed;
}
Verschwindende wrote:
- CSS doesn’t make pies
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
oncontextmenu and bgproperties
Tue, 2006-06-13 13:51
#10
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
there is no attribute
1) How do I convert my code based on this comment?
All the attribute attached to <embed> are invalid, because embed is a proprietary netscape element and is not a part of html. Use the object tag.
2) How do I convert an id to a class?
The id, «SCOMenu» is used multiple times, not allowed. Make it a class, and you should be ok.
Thanks,
Cyndi
Tue, 2006-06-13 14:00
#11
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
html tutorials
There’s no doubt about that as I usually work in VB. The «reality» of that is this — I have 50 hours to convert the VB which GENTERATES the html code. SO, I have to know the «FIX» before I add the HTML CODE to VB. Then I must recompile the .DLL that contains the VB code and register the .DLL. THEN, I have to run the courseware that was created in VB and publish the output for HTML and THEN run it through the W3C Validator. If you are able to provide specific guidance please do post to this thread as any help at all would be greatly appreciated.
Tue, 2006-06-13 15:10
#12
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
object vs embed
Please tell me how to convert an Embed tag to an Object tag.
Tue, 2006-06-13 15:11
#13
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
Class instead of ID
How do I change an ID to a Class?
Tue, 2006-06-13 15:13
#14
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
attribute "SRC"
How do I update an attribute to make it pass w3c validation.
there is no attribute «SRC» is an error we are getting
Tue, 2006-06-13 15:21
#15
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
sample pages and content
This page has W3C errors
The W3C Errors I am working on at the moment are
«there is no attribute ID»
«there is no attribute SRC»
«there is no attribute embed»
<!DOCTYPE HTML PUBLIC «-//W3C//DTD 4.01 Transitional//EN» «http//www.w3.org/TR/html4/loose.dtd»>
<html><head><title>021FUELOIL-in-4</title>
<link rel=»stylesheet» type=»text/css» href=»css/lesson.css»>
<link rel=»stylesheet» type=»text/css» href=»css/21bt640_416.css»>
</head><body oncontextmenu=»return false;» bgproperties=fixed>
<embed id=Video1 src=video/vi002302.avi autostart=false style=»visibilityshow;» />
<span id=Narration1></span>
<span id=Text1>References</span>
<span id=Text2></span>
<script type=»Text/JavaScript»>if (window.parent!=window && parent.isReady==1){parent.Menu.SetPage2(4); }</script>
<span id=SCOMenu style=»visibilityhidden;»><iframe id=PopupMenu src=dropmenu.htm></iframe></span>
</body></html>
Please if you have time — provide insight so that I can fix the errors.
Thanks,
Cyndi
Tue, 2006-06-13 15:58
#16
roytheboy
Offline
Guru
North Wales, UK
Last seen: 9 years 46 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41
there is no attribute
cyndi — you’re obviously in way over your head here. You need to read some tutorials and at least try to understand the basics of HTML! We are not here to do your work or coursework for you — we are here to point people in the right direction regarding CSS, or to share CSS techniques, or to discuss CSS problems. You’ve got 50 hours, so spend a few of them learning the basics. Even two hours of reading will help you with your multiple problems!
Life’s a b*tch and then you die!
Tue, 2006-06-13 16:07
#17
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
css techniques
So then, would the offending code be better off in a CSS, or would I be able to rework it in the html page — in your humble opinion?
Tue, 2006-06-13 16:19
#18
roytheboy
Offline
Guru
North Wales, UK
Last seen: 9 years 46 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41
there is no attribute
What is a CSS?
My humble opinion remains the same — you need to at least grasp the very basics before you’ll have any chance of validating that page!
Life’s a b*tch and then you die!
Tue, 2006-06-13 17:27
#19
gary.turner
Offline
Moderator
Dallas
Last seen: 2 years 14 weeks ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858
there is no attribute
RTB has the truth of it. Without a proper knowledge base, you won’t understand why things have gone wrong, nor how to fix them.
See ALA’s Flash Satay
On the id vs. class thing, you’ll know that as soon as you’ve learned even a bit about css.
cheers,
gary
If your web page is as clever as you can make it, it’s probably too clever for you to debug or maintain.
Tue, 2006-06-13 17:36
#20
thepineapplehead
Offline
Moderator
Last seen: 1 year 7 weeks ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819
there is no attribute
To quickly go through the errors:
Change an ID to a class:
change all generated id=»» to class=»» and change the # before the CSS name to a . (eg #myname becomes .myname)
The embed stuff is in the Flash Satay article.
The «no attribute SRC» we need to see what code is being output with that in it.
Verschwindende wrote:
- CSS doesn’t make pies
Tue, 2006-06-13 18:42
#21
Anonymous
Guru
Re: html tutorials
cyndi brown wrote:
…If you are able to provide specific guidance please do post to this thread as any help at all would be greatly appreciated.
Why do I always catch this crap?
As said above by the good folk that help here you are in way over your head. If you can’t handle the work then you need to hire someone. Seriously. That’s how a business works, just like a team. You can’t be expected to know or do everything so you hire someone that compliments you or covers your shortcomings.
Tue, 2006-06-13 19:17
#22
cyndi brown
Offline
Regular
Last seen: 17 years 1 week ago
Joined: 2006-06-07
Posts: 14
Points: 0
ideas appreciated
KK5st and the pineapplehead ~
Thank you for the ideas. idea I am a VB developer who only wants to writeout html that passes the W3C Validation. Thank you for the help. There are only a few lines of code andor concepts that are causing me trouble, so the perspective is appreciated.
Cyndi