search
HomeWeb Front-endHTML TutorialHTML/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

{color: rbg250,250,250/#000000/red;}

(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:;}


Attribute values: normal/500 (regular); bold/600-900 (bold); bolder (bolder);

(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

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)}

Extension: Add strikethrough

(10) First line indent


{text-indent:value;}
Value is the number of words. The unit is: em;

Text-indent is a negative value and goes forward

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

(3) png: loss of images with less color, not Support animation, support transparency, it is fireworks;

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;}


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

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

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor