Nhận xét được khuyến khích thực hành trong lập trình và phát triển phần mềm nói chung, chúng có thể nêu lý do tại sao quyết định mã hóa được đưa ra hoặc giải thích những gì cần phải làm để cải thiện mã bạn đang làm việc.
HTML có thể không được coi là ngôn ngữ lập trình nhưng nó chắc chắn có nhận xét. Trong HTML, các bình luận chủ yếu được sử dụng để chỉ ra các đoạn mã như tiêu đề, thanh bên hoặc các thành phần tùy chỉnh
Nhận xét không hiển thị trong HTML của bạn [như trong bất kỳ ngôn ngữ nào có nhận xét], nhưng bạn có thể hiển thị chúng trên trang cho mục đích gỡ lỗi
Hãy tìm hiểu làm thế nào chúng ta thực sự có thể thực hiện điều này
Các thẻ HTML [bao gồm cả nhận xét HTML] được biểu diễn dưới dạng các nút trong cây DOM và mỗi nút có thuộc tính
p {
font-weight: bold;
line-height: 1.618;
font: 18px Georgia;
}
pre {
font-weight: bold;
text-decoration: underline;
font-family: Georgia;
}
.container {
width: 70%;
margin: 0 auto;
}
.form__label {
display: block;
margin-bottom: 0.6em;
}
.btn {
border: none;
padding: 1.2em;
background-color: #cd5b45;
color: #ffffff;
}
.btn.success {
background-color: green;
}
.btn:hover {
cursor: pointer;
}
.hidden {
display: none;
}
.show {
display: block;
}
#comments_section {
border: 2px solid #1560bd;
box-shadow: -3px 3px #1560bd;
padding: 1.2em;
position: relative;
}
.remove-paragraph {
padding: 0.8em;
position: absolute;
top: 0em;
right: 0em;
border: 50%;
}
.remove-paragraph:hover {
cursor: pointer;
font-weight: bold;
}
.remove-paragraph::before {
content: 'x';
}
#commentsInCode {
background-color: #cccccc;
}
#commentsInCode pre {
padding: 1em;
}
#commentsInCode h2 {
text-align: center;
}
.hidden {
display: none;
}
.show {
display: block;
}
1 là một giá trị số xác định loại nútĐể có được giá trị số, định dạng là
p {
font-weight: bold;
line-height: 1.618;
font: 18px Georgia;
}
pre {
font-weight: bold;
text-decoration: underline;
font-family: Georgia;
}
.container {
width: 70%;
margin: 0 auto;
}
.form__label {
display: block;
margin-bottom: 0.6em;
}
.btn {
border: none;
padding: 1.2em;
background-color: #cd5b45;
color: #ffffff;
}
.btn.success {
background-color: green;
}
.btn:hover {
cursor: pointer;
}
.hidden {
display: none;
}
.show {
display: block;
}
#comments_section {
border: 2px solid #1560bd;
box-shadow: -3px 3px #1560bd;
padding: 1.2em;
position: relative;
}
.remove-paragraph {
padding: 0.8em;
position: absolute;
top: 0em;
right: 0em;
border: 50%;
}
.remove-paragraph:hover {
cursor: pointer;
font-weight: bold;
}
.remove-paragraph::before {
content: 'x';
}
#commentsInCode {
background-color: #cccccc;
}
#commentsInCode pre {
padding: 1em;
}
#commentsInCode h2 {
text-align: center;
}
.hidden {
display: none;
}
.show {
display: block;
}
2 trong đó nút là một phần tử HTML. Giá trị số là một giá trị lớn hơn p {
font-weight: bold;
line-height: 1.618;
font: 18px Georgia;
}
pre {
font-weight: bold;
text-decoration: underline;
font-family: Georgia;
}
.container {
width: 70%;
margin: 0 auto;
}
.form__label {
display: block;
margin-bottom: 0.6em;
}
.btn {
border: none;
padding: 1.2em;
background-color: #cd5b45;
color: #ffffff;
}
.btn.success {
background-color: green;
}
.btn:hover {
cursor: pointer;
}
.hidden {
display: none;
}
.show {
display: block;
}
#comments_section {
border: 2px solid #1560bd;
box-shadow: -3px 3px #1560bd;
padding: 1.2em;
position: relative;
}
.remove-paragraph {
padding: 0.8em;
position: absolute;
top: 0em;
right: 0em;
border: 50%;
}
.remove-paragraph:hover {
cursor: pointer;
font-weight: bold;
}
.remove-paragraph::before {
content: 'x';
}
#commentsInCode {
background-color: #cccccc;
}
#commentsInCode pre {
padding: 1em;
}
#commentsInCode h2 {
text-align: center;
}
.hidden {
display: none;
}
.show {
display: block;
}
3Bảng bên dưới liệt kê các giá trị trả về có thể
ValueMeaning1ELEMENT_NODE2ATTRIBUTE_NODE3TEXT_NODE4CDATA_SECTION_NODE5ENTITY_REFERENCE_NODE6ENTITY_NODE7PROCESSING_INSTRUCTION_NODE8COMMENT_NODE9DOCUMENT_NODE10DOCUMENT_TYPE_NODE11DOCUMENT_FRAGMENT_NODE12NOTATION_NODE
Từ bảng trên, rõ ràng là các nhận xét HTML có giá trị bằng số là
p {
font-weight: bold;
line-height: 1.618;
font: 18px Georgia;
}
pre {
font-weight: bold;
text-decoration: underline;
font-family: Georgia;
}
.container {
width: 70%;
margin: 0 auto;
}
.form__label {
display: block;
margin-bottom: 0.6em;
}
.btn {
border: none;
padding: 1.2em;
background-color: #cd5b45;
color: #ffffff;
}
.btn.success {
background-color: green;
}
.btn:hover {
cursor: pointer;
}
.hidden {
display: none;
}
.show {
display: block;
}
#comments_section {
border: 2px solid #1560bd;
box-shadow: -3px 3px #1560bd;
padding: 1.2em;
position: relative;
}
.remove-paragraph {
padding: 0.8em;
position: absolute;
top: 0em;
right: 0em;
border: 50%;
}
.remove-paragraph:hover {
cursor: pointer;
font-weight: bold;
}
.remove-paragraph::before {
content: 'x';
}
#commentsInCode {
background-color: #cccccc;
}
#commentsInCode pre {
padding: 1em;
}
#commentsInCode h2 {
text-align: center;
}
.hidden {
display: none;
}
.show {
display: block;
}
4, đây là yêu cầu quan trọng để thực sự nhận được nhận xét và sau đó hiển thị nó trên bất kỳ phần nào của trangYêu cầu khác là giá trị
p {
font-weight: bold;
line-height: 1.618;
font: 18px Georgia;
}
pre {
font-weight: bold;
text-decoration: underline;
font-family: Georgia;
}
.container {
width: 70%;
margin: 0 auto;
}
.form__label {
display: block;
margin-bottom: 0.6em;
}
.btn {
border: none;
padding: 1.2em;
background-color: #cd5b45;
color: #ffffff;
}
.btn.success {
background-color: green;
}
.btn:hover {
cursor: pointer;
}
.hidden {
display: none;
}
.show {
display: block;
}
#comments_section {
border: 2px solid #1560bd;
box-shadow: -3px 3px #1560bd;
padding: 1.2em;
position: relative;
}
.remove-paragraph {
padding: 0.8em;
position: absolute;
top: 0em;
right: 0em;
border: 50%;
}
.remove-paragraph:hover {
cursor: pointer;
font-weight: bold;
}
.remove-paragraph::before {
content: 'x';
}
#commentsInCode {
background-color: #cccccc;
}
#commentsInCode pre {
padding: 1em;
}
#commentsInCode h2 {
text-align: center;
}
.hidden {
display: none;
}
.show {
display: block;
}
5. p {
font-weight: bold;
line-height: 1.618;
font: 18px Georgia;
}
pre {
font-weight: bold;
text-decoration: underline;
font-family: Georgia;
}
.container {
width: 70%;
margin: 0 auto;
}
.form__label {
display: block;
margin-bottom: 0.6em;
}
.btn {
border: none;
padding: 1.2em;
background-color: #cd5b45;
color: #ffffff;
}
.btn.success {
background-color: green;
}
.btn:hover {
cursor: pointer;
}
.hidden {
display: none;
}
.show {
display: block;
}
#comments_section {
border: 2px solid #1560bd;
box-shadow: -3px 3px #1560bd;
padding: 1.2em;
position: relative;
}
.remove-paragraph {
padding: 0.8em;
position: absolute;
top: 0em;
right: 0em;
border: 50%;
}
.remove-paragraph:hover {
cursor: pointer;
font-weight: bold;
}
.remove-paragraph::before {
content: 'x';
}
#commentsInCode {
background-color: #cccccc;
}
#commentsInCode pre {
padding: 1em;
}
#commentsInCode h2 {
text-align: center;
}
.hidden {
display: none;
}
.show {
display: block;
}
5 như tên ngụ ý là nội dung của nútDữ liệu nút mẫuĐây là mã HTML
The core functionality of this app requires
JavaScript to work. Please enable JavaScript
Yes
No
Show Comments
Hide Comments
Comments in your code