LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   HTML code not centering (https://www.linuxquestions.org/questions/programming-9/html-code-not-centering-4175468026/)

Dafydd 07-01-2013 12:13 PM

HTML code not centering
 
What is it about the 1st line that WILL NOT center but the second will?
Code:

<html><head></head><body>
<p align="center"><h1>Lydia Ann Fly Masters</h1></p>
<p align="center"><b>Supporting Casting for Recovery</b></p>
<p><i>A note from Lydia Ann Fly Masters, Casting for Recovery and Alamo Fly Fishers.</i><<p/>
<p>Dear Friends and Anglers:</p>
</body></html>

Chrome, Opera, Foxfire, and Evolution all show the same.

I'm stumped.
view the whole web page here. http://texasflyfishers.org

Thanks for any insight offered.
Dave

Doc CPU 07-01-2013 12:41 PM

Hi there,

Quote:

Originally Posted by Dafydd (Post 4981835)
What is it about the 1st line that WILL NOT center but the second will?
Code:

<html>
<head></head>
<body>
<p align="center"><h1>Lydia Ann Fly Masters</h1></p>
<p align="center"><b>Supporting Casting for Recovery</b></p>
<p><i>A note from Lydia Ann Fly Masters, Casting for Recovery and Alamo Fly Fishers.</i><<p/>
<p>Dear Friends and Anglers:</p>
</body>
</html>

[line breaks added to the code for clarity]

the answer is simple: This is invalid HTML. A paragraph (p element) must not contain another block level element. Nesting an h1 element inside p isn't allowed. So when the browser encounters the opening <h1> tag, it decides internally that the paragraph must end before that. That leaves an orphaned closing </p> at the end of the line, which is simply ignored.

Solution: Don't use a p element for that line. A headline is not supposed to be packaged into a paragraph.

And don't forget the title element inside the head - it's required by the spec.

By the way: You seem to have missed the evolution of web authoring over the last ten or more years. Controlling visual aspects with HTML attributes, or using HTML elements only for visual purposes is deprecated since long. That's where the power of CSS should be used instead. (This is not a "must", but an urgent "should".)

[X] Doc CPU

Dafydd 07-01-2013 04:32 PM

Quote:

Nesting an h1 element inside p isn't allowed.
Quote:

A headline is not supposed to be packaged into a paragraph.
I have trouble using the correct word to search for. When you mentioned "headline", things snapped and I went to the 'W3school' site, and it produced the below line of code that works.
Code:

<h1 align="center">Lydia Ann Fly Master</h1>
Quote:

By the way: You seem to have missed the evolution of web authoring over the last ten or more years.
I took over this website about 10 years ago when the maintainer got transferred. Have tried to give it away, but no one in the club wants it. They bitch if somethings wrong but would rather go fishing.

What I code is from books of that time perion.

Thanks for you support and knowledge.
Dave

Doc CPU 07-02-2013 11:25 AM

Hi there,

good to hear you got somewhere. :-)

Quote:

Originally Posted by Dafydd (Post 4981965)
I took over this website about 10 years ago when the maintainer got transferred. Have tried to give it away, but no one in the club wants it. They bitch if somethings wrong but would rather go fishing.

I know that kind of thing. *sigh*
For me, it's not websites (though I do that, too, sometimes), but one or the other software project. Some of them from the bronze age. On the one hand, that's a fine thing, because if you're the only one around who's still able to program some old 8bit CPU in assembler, you're an important guy (and hopefully get paid appropriately, which I can't complain about). And to be honest, it's actually some kind of challenge, some sort of fun to get along with such archaic systems. On the other hand, you tend to moan something like "oh no, not again", when you see an ominous e-mail in your inbox ...
Yet I hope these old machines may still work and be used for some time ...

Quote:

Originally Posted by Dafydd (Post 4981965)
What I code is from books of that time period.

That explains a lot. And I agree: It wouldn't make sense to transplant a sixteen year old accident victim's heart to an old guy of ninety.

By the way, I consider myself more or less fluent in English (I've been mistaken for an American on several occasions), but I didn't know yet that "angling" (as a verb) is the same as "fishing". I knew the word "angle" as a term in geometry, but wasn't aware of another meaning, even though it's almost the same as the German verb "angeln" (infinitive).

[X] Doc CPU

Dafydd 07-03-2013 01:06 AM

Quote:

ETYMOLOGY: Middle English anglen, from angel, fishhook, from Old English."
Wasn't OE originally brought across the channel by the Germanic tribes as they invaded Britan, circa 13 century?


All times are GMT -5. The time now is 09:52 AM.