当前位置: 首页 > Web前端 > HTML

基于WEB的HTML中各标签的默认样式

时间:2023-04-02 23:43:50 HTML

在HTML中,了解各标签的默认样式有助于理解代码的性能,也有助于简化代码。(???????)head{display:none}body{margin:8px;line-height:1.12}button,textarea,input,object,select{display:inline-block;}ol,ul,dir,menu,dd{margin-left:40px}i,cite,em,var,address{font-style:italic}//块级元素html,body,div,ol,p,ul,h1,h2,h3,h4,h5,h6,address,blockquote,form,dd,dl,dt,fieldset,frame,frameset,noframes,center,dir,hr,menu,pre{display:block}//列表元素li{display:list-item}ol{list-style-type:decimal}olul,ulol,ulul,olol{margin-top:0;margin-bottom:0}//标题h1{font-size:2em;边距:.67em0}h2{字体大小:1.5em;边距:.75em0}h3{字体大小:1.17em;margin:.83em0}h4,p,blockquote,ul,fieldset,form,ol,dl,dir,menu{margin:1.12em0}h5{font-size:.83em;边距:1.5em0}h6{字体大小:.75em;margin:1.67em0}h1,h2,h3,h4,h5,h6,b,strong{font-weight:bolder}//伪类br:before{content:”\A”}:before,:after{white-space:前行}:link,:visited{text-decoration:underline}:focus{outline:thindottedinvert}//表格table{display:table}tr{display:table-row}thead{display:table-header-group}tbody{display:table-row-group}tfoot{display:table-footer-group}col{display:table-column}colgroup{display:table-column-group}td,th{display:table-cell;}caption{display:table-caption}th{font-weight:bolder;text-align:center}caption{text-align:center}table{border-spacing:2px;}thead,tbody,tfoot{vertical-align:middle}td,th{vertical-align:inherit}//其他元素blockquote{margin-left:40px;margin-right:40px}pre,tt,code,kbd,samp{font-family:monospace}pre{white-space:pre}big{font-size:1.17em}small,sub,sup{font-size:.83em}sub{vertical-align:sub}sup{vertical-align:super}s,strike,del{text-decoration:line-through}hr{border:1pxinset}u,ins{text-decoration:underline}center{text-align:center}abbr,acronym{字体变体:小型大写字母;字母间距:0.1em}BDO[DIR="ltr"]{方向:ltr;unicode-bidi:bidi-override}BDO[DIR="rtl"]{方向:rtl;unicode-bidi:bidi-override}/*定义BDO元素属性为DIR="ltr/rtl"时的默认文本读写显示顺序*/*[DIR="ltr"]{direction:ltr;unicode-bidi:embed}*[DIR="rtl"]{direction:rtl;unicode-bidi:embed}/*定义任意元素属性为DIR="rtl/rtl"时默认的文本读写显示顺序*/@mediaprint{h1{page-break-before:always}h1,h2,h3,h4,h5,h6{page-break-after:avoid}ul,ol,dl{page-break-before:avoid}}/*定义标题和列表的默认打印样式*/浏览器默认样式1、页边距IE默认为10px,通过body的边距属性设置FF默认为8px。要通过bodypadding属性设置清除页边距,必须清除这两个属性值。body{margin:0;padding:0;}2.段落间距IE默认为19px。-top属性默认设置FF为1.12em,通过p的margin-bottom属性设置p默认屏蔽显示。清除段间距,一般可以设置p{margin-top:0;margin-bottom:0;}3、标题样式h1~h6默认以粗体显示:font-weight:bold;默认大小请参考上表和h1{font-size:xx-large;}h2{font-size:x-large;}h3{font-size:large;}h4{font-size:medium;}h5{font-size:small;}h6{font-size:x-small;}大浏览器默认字体大小为16px,等于medium,h1~h6元素默认分块显示。字体显示为粗体,清除标题样式,一般可以设置hx{font-weight:normal;font-size:value;}4.列表样式IE默认为40px,FF默认为40px通过ul和ol的margin属性。padding属性设置dl无缩进,但内部描述元素dd默认缩进40px,name元素dt不缩进。清除列表样式,一般可以设置ul,ol,dd{list-style-type:none;margin-left:0;padding-left:0;}元素居中。IE默认为text-align:center;FF默认为margin-left:auto;margin-right:auto;5。超链接样式默认带下划线的样式,显示颜色为蓝色,访问的超链接变为紫色。清除链接样式,一般可以设置一个{text-decoration:none;color:#colorname;}6.鼠标样式IE默认为cursor:hand;FF默认为游标:指针;这个说法在IE7下也有效,图片链接样式IE默认为紫色2px边框线FF默认要清除图片链接样式为蓝色2px边框线,一般可以设置img{border:0;}