The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Need help setting width of website HTML Texas
Mike777
post Mar 25 2022, 10:18 PM
Post #1


Member
***

Group: Members
Posts: 39
Joined: 20-March 22
Member No.: 28,287



I need the text of my entire HTML website www.texasmilitia.info to be 640 wide so it is not any wider than my images and so it is not too wide for smart phones.

This is the only code I get to work to make the width of all the text on my entire website to be 640 in width.
<table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>

But https://validator.w3.org says,
document type does not allow element "TABLE" here; missing one of "TH", "TD" start-tag
…e width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").


So here is my HTML code before my width setting:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>texas militia</title>
<meta name="description" content= "militias are not illegal, join texas militia, texas militia training exercise, militias are authorized by US Constitution, training free of charge, east texas">
<meta name="robots" content= "index, nofollow">
</head>
<Body bgColor="#FFFFFF">
<table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>


Can anyone tell me what the correct HTML code should be?

Everything else I try on the front and end of my line of code
<TR></TR>, <TABLE></TABLE>, <TH></TH>, and <TD></TD>
makes it to wide.

In case it matters this is the code at the end of my webpage:

<center><img src="images/TX flagbar.gif" width="468" height="25" alt=""></center>
</font></td>
</tr>
</table>
</script>
</body>
</html>


This post has been edited by Mike777: Mar 25 2022, 10:20 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 26 2022, 07:43 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(Mike777 @ Mar 26 2022, 04:18 AM) *

This is the only code I get to work to make the width of all the text on my entire website to be 640 in width.
<table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>

Keep in mind that this very large CELLPADDING value will reduce the available space for the text even more.

QUOTE
CODE
<table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>

The TR element is missing, a table needs at least one row and one cell. Can't say if that's the cause of the validator error though.

QUOTE
In case it matters this is the code at the end of my webpage:

CODE
[b]<center><img src="images/TX flagbar.gif" width="468" height="25" alt=""></center>
</font></td>
</tr>
</table>
</script>
</body>
</html>[/b]

The </script> end tag shouldn't be there.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 26 2022, 12:48 PM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



You can give any element a width with CSS. For instance the below will give you 640px width and everything centered.

CODE
<body style="width: 640px; margin: auto; border: 5px solid red">

<p>
Web style sheets have been around for a number of years, but their power and importance went largely unnoticed since few implementations existed. Web authors, anxious to add creativity to their pages by influencing the presentation, began to use Netscape's proprietary extensions rather than the more powerful style sheets. This was quite natural, since Netscape's proprietary extensions could be seen by a significant portion of Web users, while few would see style sheet enhancements.

Today, more and more browsers are implementing style sheets, opening authors' eyes to unique features that allow influence over presentation while preserving platform independence. The advantages of style sheets became apparent, as did the disadvantages of continually creating more HTML tags for presentation effects.

Netscape's BODY attributes are now widely accepted on the Web, and have become standardized in HTML 3.2. Yet BGCOLOR, TEXT and friends simply do not provide the flexibility of style sheets. Most background images would leave a page unreadable to someone whose display only offered 16 colors; many pages are difficult to read with only 256 colors. With conventional BODY attributes, an author must choose whether the benefits of a background image outweigh the costs; with style sheets, an author can offer a number of different images, in different style sheets, so that the user can choose the "24-bit style sheet" or "8-bit style sheet," depending on how many colors his or her system can display. If no author-supplied style suits the user, he or she can simply ignore the author's style.

Style sheets can make an author's life much easier. While one could use <HR WIDTH="75%" SIZE=5 ALIGN=center> for every horizontal rule, this becomes very cumbersome for the author. With style sheets, one only needs to specify such presentational preferences once, and the style can be applied to an entire site. And if the author decides that WIDTH="50%" would be better, then he or she only needs to change this preference in one place, rather than having to search through hundreds of pages to change the HTML. Not only that, but style sheets also reduce download time when one file contains all the style information.

Style sheets also offer much more flexibility in terms of the presentation effects that they provide. Properties such as color, background, margin, border, and many more can be applied to all elements. With just HTML and its proprietary extensions, one must rely on attributes like BGCOLOR, which are only available for a few elements. Style sheets give the flexibility of applying a style to all paragraphs, or all level-two headings, or all emphasized text.
</p>


</body>



A fixed 640px width will look horrible on a large screen though...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Mike777
post Mar 26 2022, 02:06 PM
Post #4


Member
***

Group: Members
Posts: 39
Joined: 20-March 22
Member No.: 28,287



Thanks Christian J, I have removed the The </script> end tag.

I put <TR> here:
12 <TR><table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>

It displays fine keeping the narrow width but the validator says:
"Line 12, Column 4: document type does not allow element "TR" here
<TR><table width="640" border="0" cellspacing="0" cellpadding="100" align="cent…
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

Line 12, Column 83: document type does not allow element "TABLE" here; missing one of "TH", "TD" start-tag
…le width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

Line 12, Column 87: start tag for "TR" omitted, but its declaration does not permit this
…le width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Mike777
post Mar 26 2022, 02:30 PM
Post #5


Member
***

Group: Members
Posts: 39
Joined: 20-March 22
Member No.: 28,287



Thanks for the help pandy, when I change line 12 to:
12<body style="width: 640px; margin: auto; border: 5px">
I displays just a little narrower on my monitor but still looks good to me but this is the error message I get:

<body style="width: 640px; margin: auto; border: 5px">
Line 12, Column 54: document type does not allow element "BODY" here
<body style="width: 640px; margin: auto; border: 5px">The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

I have never used CSS before and I left my ending code unchanged.

<center><img src="images/TX flagbar.gif" width="468" height="25" alt=""></center>
</font></td>
</tr>
</table>
</body>
</html>


This post has been edited by Mike777: Mar 26 2022, 02:38 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 26 2022, 02:44 PM
Post #6


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(Mike777 @ Mar 26 2022, 08:06 PM) *

I put <TR> here:
12 <TR><table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>

No, it needs to be inside the table element, like this:

CODE
<table>
<tr>
<td>cell</td>
</tr>
</table>

See also https://htmlhelp.com/reference/html40/tables/table.html

But it's better to use CSS for layout and decoration, like pandy suggested. HTML tables are primarily meant for tabular data.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 26 2022, 02:47 PM
Post #7


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(Mike777 @ Mar 26 2022, 08:30 PM) *

this is the error message I get:

<body style="width: 640px; margin: auto; border: 5px">
Line 12, Column 54: document type does not allow element "BODY" here

Maybe something's wrong above the <body ...> start tag?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Mike777
post Mar 26 2022, 04:12 PM
Post #8


Member
***

Group: Members
Posts: 39
Joined: 20-March 22
Member No.: 28,287



Christian J, In regards to my code line
"12 <TR><table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>
you said, "No, it needs to be inside the table element, like this":
CODE
<table>
<tr>
<td>cell</td>
</tr>
</table>

I don't understand. How should my line 12 of code be written?

You also said, "Maybe something's wrong above the <body ...> start tag?"
I don't see it. Could you look for me please?

Here is my beginning and ending code in case it helps:
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>texas militia</title>
6 <meta name="description" content= "militias are not illegal, join texas militia, texas militia training exercise, militias are authorized by US Constitution, training free of charge, east texas">
7 <meta name="robots" content= "index, nofollow">
8 </head>
9
10 <Body bgColor="#FFFFFF">
11
12 <table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>
13
14 <font face="Verdana" size="3" color="#0000FF">
15
16 <center><img src="images/TX flagbar.gif" width="468" height="25" alt="">
17
18 <h1>Texas Militia</h1>
19 <p><font face="Verdana" size="1" color="#0000FF"></p>
20 <img src="images/TX flagbar.gif" width="468" height="25" alt=""><br>
21
22 <h2>Texas Militia Training Exercise Saturday, May 14, </h2>
23
24 <p><b>Scroll down for more information & keep reading, it's all one long webpage.</b></p>
25
26 <font face="Verdana" size="3" color="#000000">
27
28 <img src="images/GC3.jpg" width="634" height="506" alt="">
29
30 <br>
32
32 <font face="Verdana" size="3" color="#FF0000">United Nations Door To Door Gun Confiscation<br>Is this a vision of our future?<font face="Verdana" size="3" color="#0000FF"></p></center>
33
34 <p><b>Amendment II United States Constitution<br>
35
36 <i>"A well regulated militia being necessary to the security of a free State, the right of the People to keep and bear arms shall not be infringed."</i></b></p>
37
38 <p><b>"All laws which are repugnant to the Constitution are null and void." Marbury vs. Madison 5 US (2 Cranch) 137, 174, 176, (1803) <br></b>
39 The United States Constitution is the supreme law of the land.</p>
40 <center><img src="images/TX flagbar.gif" width="468" height="25" alt=""></center>
41
42 <p>Militias are not in favor of having another revolution in America. We are for restoring a literal interpretation of the United States Constitution as the founding fathers intended with a strong emphasis on the bill of rights, states rights, and a limited federal government. Militias are not illegal. Militias are authorized by the US Constitution.</p>
43
44 <p>If you are a rifle owning USA Citizen who is willing to uphold and defend the United States Constitution against all enemies both foreign and domestic then you are militia.</p>

46 <h3>To join our Texas Militia:</h3>
47 You must be a rifle owning USA Citizen who is willing to uphold and defend the United States Constitution against all enemies both foreign and domestic.<br>
48 You must be physically fit enough to patrol keeping up with us carrying at least your rifle, 6 spare loaded magazines, and two quarts of water.<br>
49 You must come out and train with us.</p>
50
51 <p>Militiamen realize, as did the founding fathers who threw off the tyranny of the British; that our rights come directly from God himself who is a higher authority than any government.</p>
52
53 <p>On April 19, 1775 when government troops marched on Lexington and Concord to begin gun confiscation it was militiamen who stopped them firing the shot against tyranny that was heard around the world which started the United States of America. Without the militia there never would have been a USA.<p>
54
55 <p>Militias are for enforcing the US Constitution and recognizing it as the supreme law of the land superior to any international treaties and superior to any Untied Nations rulings. Militias are the last line of defense against tyranny and invasion.</p>
56
57 <p>The Second Amendment is not about the right to keep firearms to go hunting. The Second Amendment is about the right of the people to keep and bear firearms to prevent a tyrannical government from infringing upon our God given rights and to ensure our ability to uphold and defend the constitution against all enemies both foreign and domestic.</p>
58

sniped

526
527 <center><img src="images/TX flagbar.gif" width="468" height="25" alt=""></center>
528 </font></td>
529 </tr>
530 </table>
531 </body>
532 </html>




User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 26 2022, 04:32 PM
Post #9


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(Mike777 @ Mar 26 2022, 10:12 PM) *

Christian J, In regards to my code line
"12 <TR><table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><td>
you said, "No, it needs to be inside the table element, like this":
CODE
<table>
<tr>
<td>cell</td>
</tr>
</table>

I don't understand. How should my line 12 of code be written?

Like this:

CODE
<table width="640" border="0" cellspacing="0" cellpadding="100" align="center">
<tr>
<td>

(a table contains rows, and each row contains cells). By the way, you don't need separate lines for the <table>, <tr> and <td> tags, that's up to you what you think is the easiest to read.

QUOTE
You also said, "Maybe something's wrong above the <body ...> start tag?"
I don't see it. Could you look for me please?

I get no such error with the code example you posted.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Mike777
post Mar 26 2022, 05:54 PM
Post #10


Member
***

Group: Members
Posts: 39
Joined: 20-March 22
Member No.: 28,287



Thank you very much Christian J, changing line 12 to
<table width="640" border="0" cellspacing="0" cellpadding="100" align="center"><tr><td>
Fixed it!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 26 2022, 08:00 PM
Post #11


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



QUOTE(Christian J @ Mar 26 2022, 08:47 PM) *

QUOTE(Mike777 @ Mar 26 2022, 08:30 PM) *

this is the error message I get:

<body style="width: 640px; margin: auto; border: 5px">
Line 12, Column 54: document type does not allow element "BODY" here

Maybe something's wrong above the <body ...> start tag?


No. You just need to insert it in a complete document, with doctype, HEAD, TITLE and so on.
https://htmlhelp.com/reference/html40/structure.html#doc
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Mike777
post Mar 26 2022, 08:51 PM
Post #12


Member
***

Group: Members
Posts: 39
Joined: 20-March 22
Member No.: 28,287



Thanks for the help and the link pandy.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 27 2022, 11:06 AM
Post #13


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Mar 27 2022, 03:00 AM) *

No. You just need to insert it in a complete document, with doctype, HEAD, TITLE and so on.
https://htmlhelp.com/reference/html40/structure.html#doc

But don't use the Strict Doctype in that example, or the validator will become much stricter too. laugh.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Mike777
post Mar 27 2022, 01:22 PM
Post #14


Member
***

Group: Members
Posts: 39
Joined: 20-March 22
Member No.: 28,287



Thanks Christian J, I had noticed the "strict" and I kept with the
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
code you gave me.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 04:33 AM