TAILIEUCHUNG - HTML cơ bản - p 6

34 Chapter 2: The HTML Language marks the end of the document body. Clicking below the horizontal rule will not have any effect. It is just extra space the browser put there because the document is shorter than the browser window. . The window’s width does not matter. The document will always occupy the window’s full width. A click will work anywhere above the rule, except at the very edges of the page. This is because there is space between the document’s window and the body content. This space is called padding. The heading text does not change color when you click in the. | 34 Chapter 2 The HTML Language marks the end of the document body. Clicking below the horizontal rule will not have any effect. It is just extra space the browser put there because the document is shorter than the browser window. The window s width does not matter. The document will always occupy the window s full width. A click will work anywhere above the rule except at the very edges of the page. This is because there is space between the document s window and the body content. This space is called padding. The heading text does not change color when you click in the body. This is due to the cascading nature of CSS. Child objects inherit properties from their parents but can override and add to them. So even though the level-one heading is inside the document body the heading text does not change to red because a more specific CSS rule takes precedence. After the paragraph text changes to red there s no going back for the user short of reloading the page. It is not that the change is permanent. It is just because no behavior has been defined to allow users to go back to the initial state. The JavaScript code does not in any sense live in the space after the document body. Script elements can appear anywhere in an HTML document. In Example the script code must be placed after the body element because the browser executes scripts as they are encountered in the source code. It would be an error to reference an object before it is fully defined. There are other ways to accomplish this including calling JavaScript functions within the HTML code using special HTML event-handling attributes. Also external JavaScript libraries such as jQuery provide a means to execute functions when the document is ready that is when all the DOM objects are fully defined. This allows code to be placed apart from the HTML source. Without going into the details of jQuery syntax the equivalent jQuery code to define the body behavior of Example would look like this script type text

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.