Jump to content

html


hisoka

Recommended Posts

this : <!DOCTYPE html><html><title>Page Title</title><body> <h1>This is my first web page</h1> </body></html>and this : <!DOCTYPE html><html><body> <h1>This is my first web page</h1></body></html>and this<!DOCTYPE html><html><head> <title>My first web page</title></head><body> This is my first web page</body></html>and this<!DOCTYPE html><html><body> This is my first web page</body></html>give the same result1)if , in these examples, we can get the title without using <title>Page Title</title> so <title>Page Title</title> is useless !!?2)if we can get the title only using <title>Page Title</title> without <head></head> so <head></head> is useless too !!?"the <head> Defines information about the document" . does it mean that without <head> the document will not have an identitity and a definition and therefore it will not be shown !!? I still do not get this <head> </head>what is the difference between this:<!DOCTYPE html><html><head><title>HTML Reference</title></head><body>The content of the document......</body></html>and this :<!DOCTYPE html><html><body><head><title>HTML Reference</title>The content of the document......</head></body></html>in this script:<!DOCTYPE html><html><head> <title>My first web page</title></head><body> This is my first web page</body></html>why should we precise the title of the page in the <body></body> in order to get the title?

Link to comment
Share on other sites

The <head>...</head> holds links to external scripts, css, along with meta tags including title (which is required), the last two are picked up by search engines as part of SEO to describe the page content. None of the mention above are shown in the users browser window, whereas the <body>...</body> should hold html that will make up the website page and is viewable to the user visiting your site.

  • Like 1
Link to comment
Share on other sites

In HTML 5 it's valid to omit the <head> if the <body> element is present. I believe it's also valid to omit the <body> if the <head> element is present. Even though those elements aren't present in your code, the browser implicitly adds them. In HTML 4.01 and in XHTML it's not valid to omit the <head> or <body> elements.

 

Like davej said, browsers do their best to correct bad HTML, but that doesn't mean you shouldn't try to write good code.

  • Like 1
Link to comment
Share on other sites

This :

 

"The <head>...</head> holds links to external scripts, css, along with meta tags including title (which is required), the last two are picked up by search engines as part of SEO to describe the page content"

 

 

is equal to this :

 

Web search engines work by storing information about many web pages, which they retrieve from the HTML markup of the pages. These pages are retrieved by a Web crawler (sometimes also known as a spider) — an automated Web crawler which follows every link on the site. The site owner can exclude specific pages by using robots.txt.

The search engine then analyzes the contents of each page to determine how it should be indexed (for example, words can be extracted from the titles, page content, headings, or special fields called meta tags). Data about web pages are stored in an index database for use in later queries. A query from a user can be a single word. The index helps find information relating to the query as quickly as possible

 

So without <head><title></title><head>the web search engines would not be able to store information about the webpage content and analyse it , collect it , parse it , optimized it for the sake of the facilitation ,specification , quickness and efficacy of the information retrieval through queries and therefore the user or client would not be able to find the desired content and /or data of the webpage in the desired way.

 

 

"<body>...</body> should hold html that will make up the website page and is viewable to the user visiting your site."

 

the <body> </body> plays the role of containing the html data that are responsible for the page viewed by the client . Can we say that <body> </body> is like a VARIABLE ??????

 

What are the other drawbacks or disadvantage of not using <head></head> ???

Edited by hisoka
Link to comment
Share on other sites

using this link :

 

http://validator.w3.org/

 

I tried to validate this script and there was an error

 

 

<!DOCTYPE html><html><title>Page Title</title><body> <h1>This is my first web page</h1> </body></html>

 

(output : This is my first web page)The character encoding was not declared. Proceeding using windows-1252.

 

if the encoding was not declared in the above script how did the browser display the characters correctly?

Link to comment
Share on other sites

"if the encoding was not declared in the above script how did the browser display the characters correctly?"

 

answer :

 

"Even though those elements aren't present in your code, the browser implicitly adds them"

 

The browser will find the proper encoding type by itself .

 

I am interested in knowing how , technically, this process is done . Any link or links to read would be appreciated

Link to comment
Share on other sites

Its just a warning that you have not declared character encoding, and it usually determine the best option for you. Character encoding is used to show special characters used in foreign languages, without it you would sometimes see unrecognizable characters instead, example upside down question mark, a diamond shaped or square with unidentifiable characters within them.The body tag is a element, that contain specific body elements within it to make up a page. The html page is basicallly a text file, with html extension, php processes code and returns back as html (hyperTEXT markup language). It should return just php code in php page as in echo 'hello world' if i remeber correctly with html, body tags already defined.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...