HTML/CSS from scratch-common attributes (3)
1. css text attributes
(1) Text size {font-size:value;}
Unit: pt:9pt=12px; browser default font size is 16px
em: 1em=16px; medium:16px
large:19px
x-large:23px
xx-large:27px
(2)Font color
(3)Text font{font-family:"Font 1","Font 2","Font 3";}
The browser interprets it according to the font
Note: When the font name is in Chinese, add double quotes: "Microsoft Yahei"; a single English word does not need to be added: Arial; if there are spaces in English, add quotes: "Times New Romen";
(4) Font bold {font-weight:;}
(5)Text tilt
{font-style:itatic (italic)/oblique (oblique)/normal (cancel italic)}
(6) Horizontal alignment
{text-align:left/center/right/justify (justify both ends);}
(7)Vertical alignment
{vertical-align:top/bottom/middle;}
(8) Text line height
{line-height:normal/value;}
Measure line height: from the top of this line of text to the top of the next line of text; Single line of text: when line height = container height, vertically centered; when line height < container height Vertically upward;
Description: font abbreviation order: font-style font-weight font-size/line-height font-family;
(9) Text modification
{text-decoration:none/underline(underline)/overline(underline)/line-through(add strikethrough)}
(10) First line indent
{text-indent:value;}
Value is the number of words. The unit is: em;
It only works on the first line of text
(11) word spacing
{letter-spacing:value;}
Control the distance between English letters and Chinese characters
Extension: {word-break: break-all;}=
line break
2. Border
{border-top/bottom/right/left:1px solid/dotted/dashed/double;}
3. CSS list properties
(1) List symbol style
{list-style-type:disc(solid circle)/circle(hollow circle)/squrare(hollow square width)/none(remove list symbol);} {list-style-type:none} is equivalent to {list- style;none;}
(2) Pictures as list symbols
{list-style-image:url();}
(3) Define list symbol position
{list-style-position:ouside/inside;}
(4)Remove list symbols
{list-style:none;}
4. Background attributes
(1) Background color {background-color: value;}(2) Background image {background-image: url (path);}
(3) Background image tile {background-repeat: no-repeat (not tile )/repeat (tile)/repeat-x (horizontal tile)/repeat-y (vertical tile);}(4) Background image fixed {background-attachment: scroll (scroll)/fixed (fixed);} (5) Background image position {background-position: x y (value: 50px 50px; direction: right bottom;)} The direction positions are: horizontal (left/center/right) vertical (top/center/bottom)
(6) Abbreviation: {background:url() no-repeat center top fixed #f00;} {background:url() no-repeat center top 100px #f00 scroll;}
5. Commonly used image formats on web pages
(1) jpg: lossy compression loss of quality is suitable for images with rich colors
(2) gif: lossy compression loss of color supports transparency, animation is suitable for images with less color
Note: It requires high storage of png, higher requirement of storing gif, use gif when compatible;6. Floating (arrange vertical elements horizontally)
{float:left/right/none}
(1) Clear float {clear:left/right/both;}
Explanation: The element after floating is out of the document flow and is suspended above. When you float the element in front When the element is an element in the standard flow (without floating)
The position of the element after floating depends on the browser, and the non-floating elements behind the floating element will squeeze into the original position of the floating element.
(2) Solve the height collapse
Height collapse: The resulting condition is that the parent element does not write the height, and the child element floats;
Solution: (1) Add an empty
at the end of the floating element , write a statement div{clear:both;}
(2) Add a statement div{overflow:hidden;} to the parent element in css.
Seven, box model
1. Definition: How web page elements are displayed and their relationship with each other.
Border Border Filler Content Area
2. padding
(1) padding: padding is used to set the distance between the content of an element and the edge (border) of the element in an element on the page, padding;
(2) is used to adjust the content in the container The positional relationship in
(3) is used to adjust the position of the child element in the parent element
(4) The padding attribute is added to the parent element
Regarding the issue of whether the padding value should be reduced or not?
1. Subtraction: The parent element has width and height
2. No reduction: The parent element has no width and height;
(5) How to reduce?
Height - (top+bottom); Width - (left+right);
3. Syntax:
Four values: {padding: top right bottom left;}
One value: {padding: 20px}={padding:20px 20px 20px 20px;}
Two values: {padding: 20px 30px;}={padding: 20px 30px 20px 30px;}
Two values: {padding: 20px 30px 40px;}={padding: 20px 30px 40px 30px;}
Split: {padding-top/right/bottom/left:value;}
2. Margin
(1) Margin: margin is the blank area outside the element in the setting page;
(2) The margin attribute is added to the child element
(3) Syntax:
Four values: {margin: top right bottom left;}
One value: {margin: 20px}={padding:20px 20px 20px 20px;}
Two values: {margin: 20px 30px;}={padding: 20px 30px 20px 30px;}
Two values: {margin: 20px 30px 40px;}={padding: 20px 30px 40px 30px;}
Split: {margin-top/right/bottom/left:value;}
(1) Clear float {clear:left/right/both;}
Explanation: The element after floating is out of the document flow and is suspended above. When you float the element in front When the element is an element in the standard flow (without floating)
The position of the element after floating depends on the browser, and the non-floating elements behind the floating element will squeeze into the original position of the floating element.
(2) Solve the height collapse
Height collapse: The resulting condition is that the parent element does not write the height, and the child element floats;
Solution: (1) Add an empty
Border Border Filler Content Area
(1) padding: padding is used to set the distance between the content of an element and the edge (border) of the element in an element on the page, padding;
(2) is used to adjust the content in the container The positional relationship in
(3) is used to adjust the position of the child element in the parent element
(4) The padding attribute is added to the parent element
Regarding the issue of whether the padding value should be reduced or not?
1. Subtraction: The parent element has width and height
2. No reduction: The parent element has no width and height;
(5) How to reduce?
Height - (top+bottom); Width - (left+right);
3. Syntax:
Four values: {padding: top right bottom left;}
One value: {padding: 20px}={padding:20px 20px 20px 20px;}
Two values: {padding: 20px 30px;}={padding: 20px 30px 20px 30px;}
Two values: {padding: 20px 30px 40px;}={padding: 20px 30px 40px 30px;}
Split: {padding-top/right/bottom/left:value;}
(1) Margin: margin is the blank area outside the element in the setting page;
(2) The margin attribute is added to the child element
(3) Syntax:
Four values: {margin: top right bottom left;}
One value: {margin: 20px}={padding:20px 20px 20px 20px;}
Two values: {margin: 20px 30px;}={padding: 20px 30px 20px 30px;}
Two values: {margin: 20px 30px 40px;}={padding: 20px 30px 40px 30px;}
Split: {margin-top/right/bottom/left:value;}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.
