Font Tag

J

Jo

Hello evryone...
i jus need to know whether font tag in HTML does not require a </font>
tag.
Me parsing out text from web page source code. I have to remove the
entire tag
<font >
Any text
</font>

So i will read from <font> till I encounter a </font>
It works fine..But i recently saw that certain webpages dont have
closing </font> tag for all <font>
Is it not necessary to put a </font> tag??

What do i do now?
Kindly help..

Cheers
Annie(Jo)
 
B

Benjamin Niemann

Jo said:
Hello evryone...
i jus need to know whether font tag in HTML does not require a </font>
tag.
Me parsing out text from web page source code. I have to remove the
entire tag
<font >
Any text
</font>

So i will read from <font> till I encounter a </font>
It works fine..But i recently saw that certain webpages dont have
closing </font> tag for all <font>
Is it not necessary to put a </font> tag??

The end tag is mandatory. If it is missing, then the webpage is invalid.
What do i do now?

If you have to deal with invalid document, then you will either have to
implement some pretty complex heuristics to get a result that works similar
to how webbrowsers deal with these pages.
Or you first pipe the document through a tool like HTML Tidy
(http://www.w3.org/People/Raggett/tidy/) before you process it yourself.
 
E

Ed Mullen

Jo said:
Hello evryone...
i jus need to know whether font tag in HTML does not require a </font>
tag.
Me parsing out text from web page source code. I have to remove the
entire tag
<font >
Any text
</font>

So i will read from <font> till I encounter a </font>
It works fine..But i recently saw that certain webpages dont have
closing </font> tag for all <font>
Is it not necessary to put a </font> tag??

Yes said:
What do i do now?

I guess you'll have to double-check the code manually.
 
D

Dan

So i will read from <font> till I encounter a </font>
It works fine..But i recently saw that certain webpages dont have
closing </font> tag for all <font>
Is it not necessary to put a </font> tag??

What do i do now?

Consider using CSS for fonts? Much tidier way of doing it... and yes
<FONT> does need to be closed.

Dan - Back in alt.html for '06
 
K

kchayka

Benjamin said:
The end tag is mandatory. If it is missing, then the webpage is invalid.

And you were expecting valid code from a page that uses <font>...? ;)
 
A

Andy Dingley

i jus need to know whether font tag in HTML does not require a </font>
tag.

It doesn't require a <font> tag either. Don't use either of them.


if you absolutely _MUST_, then refactor this to use
<span style="font-family: sans-serif; font-size: 120%" >
and yes, they should be closed, paired and nested without interleaving
(if you must nest them).

But dump font and go to CSS. CSS can be tricky for some aspects, but
using it to control fonts is easy enough.
 
J

Jo

Thanks..
Im writing a HTML parser that removes the tags and keeps using sensible
text. This is in C#.Its like a tool.But, can i add another tool to it
like HTML Tidy to cleanup? Wud that be right?
In webpages, i only want the main txt to be displayed and not the Side
divisions on the left n right of the web page that mostly shows links
to the other pages.
I realised that in the web page im workin on now, has the right n left
div inside font tag of their own specified class. So i will check
whether its a font tag, then check for its class, if all are true, then
i'll remove until a </font> tag comes. This was workin fine until one
webpage showed me that </font> tag was missing for a <font> tag... Now
what do i do?
I have coded in C#..
 
J

Jim Higson

Jo said:
Thanks..
Im writing a HTML parser that removes the tags and keeps using sensible
text. This is in C#.Its like a tool.But, can i add another tool to it
like HTML Tidy to cleanup? Wud that be right?
In webpages, i only want the main txt to be displayed and not the Side
divisions on the left n right of the web page that mostly shows links
to the other pages.
I realised that in the web page im workin on now, has the right n left
div inside font tag of their own specified class. So i will check
whether its a font tag, then check for its class, if all are true, then
i'll remove until a </font> tag comes. This was workin fine until one
webpage showed me that </font> tag was missing for a <font> tag... Now
what do i do?
I have coded in C#..

Writing an error-tollerent HTML/SGML parser takes a long time. Do you have
to do this (ie it is for a school project) or could you use a preexisting
one?

TagSoup is a pretty good parser for bad HTML. See:
http://www.idealliance.org/papers/xml02/dx_xml02/html/abstract/05-06-06.html

TagSoup is in Java, but not every part of a project has to be in the same
language.
 
C

Chaddy2222

Jo said:
Hello evryone...
i jus need to know whether font tag in HTML does not require a </font>
tag.
Me parsing out text from web page source code. I have to remove the
entire tag
<font >
Any text
</font>

So i will read from <font> till I encounter a </font>
It works fine..But i recently saw that certain webpages dont have
closing </font> tag for all <font>
Is it not necessary to put a </font> tag??

What do i do now?
Kindly help..
Yes, you need to add the </font> tag in to close that tag.
If you do not do that then your code will not be valid.
 
B

Benjamin Niemann

Jo said:
Thanks..
Im writing a HTML parser that removes the tags and keeps using sensible
text. This is in C#.Its like a tool.But, can i add another tool to it
like HTML Tidy to cleanup? Wud that be right?

It can save you a lot of time. Tidy could also convert HTML to XHTML, which
could be then parsed with an XML parser and you can analyze the contents
more conviently with stuff like XPath, ...
For C# the article <http://www.devx.com/dotnet/Article/20505/0/page/1> may
help.
 
J

Jo

Hello Jim...
Yes, im writing a HTML parser as my project. Its been written in C#.
Now, the issue is with web page that don have proper closing
tags.Otherwise it works just fine.
My HTML parser works just fine...except for web pages that have no
proper closing tags cos my checks in de code checks for opening and
closing tags and removes the entire structure together.

Kindly help

Cheers
Jo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top