Home >Web Front-end >Front-end Q&A >Briefly talk about html usage
<!DOCTYPE html> <html> <head> <title>My Website</title> </head> <body> <h1>Hello, World!</h1> <p>Welcome to my website.</p> </body> </html><p>In the above code,
<!DOCTYPE html>
defines the document type and tells the browser The browser uses HTML5 to parse the document. The <html>
tag represents the root element of the document and contains the entire document. <head>
The tag contains the document's metadata, such as the title and style sheet. <title>
tag is used to set the document title, which will be displayed on the title bar of the browser window. The <body>
tag contains the main content of the document. The <h1>
and <p>
tags are used to represent titles and paragraphs, and are used to create the headline and body of text respectively.
<p>HTML tags
<p>The above is just the most basic HTML document structure. In fact, there are countless HTML tags. Here are some commonly used HTML tags:
<h1>
~<h6>
:Set title
<li>
<p>
:Paragraph
<li>
<strong>
or <b>
: Bold text
<li>
<em>
or <i>
: Italic text
<li>
<u>
: Underlined text
<li>
<strike>
or < ;del>
: Strikethrough text
<li>
<sup>
: Superscript
<li>
<sub>
: Subscript
<a>
: link
<li>
<img>
:image
<ul>
: Unordered list
<li>
<ol>
: Yes Sequence list
<li>
<li>
: List item
<table>
:Table
<li>
<thead>
:Table header
<li>
<tbody>
:Table body
<li>
<tr>
: Table row
<li>
<th>
: Header cell
<li>
<td>
: Table cell Grid
<p> The above only lists some HTML tags. In fact, there are many types of HTML tags. Through these tags, we can easily implement various elements in the web page. (This is purely a personal opinion of some of the more commonly used tags, not all tags)
<p>CSS style
<p>HTML tags can set the structure of web content, but they should make the web page more beautiful and attractive. power, CSS is particularly important.
<p>CSS (Cascading Style Sheets) is a language used to describe the style of web pages. It allows us to more flexibly control the appearance of text, images, backgrounds and other elements, as well as details such as layout.
<p>CSS Basics
<p>In fact, CSS is also composed of a set of rules, as follows:
selector { property: value; property: value; }<ul> <li>
selector
: select Container that specifies the HTML element to which the style should be applied.
<li>
property
: Attribute, used to specify the style attribute to be set.
<li>
value
: Value, used to set the value of the attribute.
<p>For example, to set the text color of all <h1>
elements to red:
h1 { color: red; }<p>At this point, CSS will change all ## in the HTML The text color of #<h1>
elements is set to red.
CSS Selector<p>In CSS, a selector is an identifier used to determine the HTML element to which a style should be applied. The following are some commonly used CSS selectors: <p>
<ul> element selector: used to specify the HTML element to which the style is to be applied, such as <li>h1, p, a.
Class selector: used to specify HTML elements with the same class to which styles are to be applied, such as <li>.header.
ID selector: used to specify HTML elements with the same ID to which the style is to be applied, such as <li>#header.
Descendant selector: used to specify the descendant elements to which the style is to be applied, such as <li>ul li.
Child element selector: used to specify the direct child element to which the style is to be applied, such as <li>ul > li.
Pseudo-class selector: used to specify the element in a specific state to which the style is to be applied, such as <li>:hover.
The above only lists some commonly used CSS selectors. In fact, there are many kinds of CSS selectors, and they can be used in combination to achieve more complex selection effects. <p>Summary<p>HTML and CSS are two technologies that must be learned for front-end development. By learning these two technologies, you can easily build and beautify web pages. Of course, JavaScript can help us achieve more complex interactive effects in web pages. Combining the three technologies can achieve more powerful web pages. <p>The above is the detailed content of Briefly talk about html usage. For more information, please follow other related articles on the PHP Chinese website!