To achieve some special effect, we need to use Javascript to dynamically change the Css attribute of a tag. For example, when the mouse goes through an image, we add a border to the image. The code may be as follows:
JavaScript code
- <Script type = "text/javascript">
- Function imageOver (e ){
- E. style. border = "1px solid red ";
- }
- Function imageOut (e ){
- E. style. borderWidth = 0;
- }
- </Script>
What are the attributes behind style in JavaScript?
JavaScript CSS Style Attribute Table
| Comparison between box labels and attributes |
| CSS syntax (Case Insensitive) |
JavaScript syntax (case sensitive) |
| Border |
Border |
| Border-bottom |
BorderBottom |
| Border-bottom-color |
BorderBottomColor |
| Border-bottom-style |
BorderBottomStyle |
| Border-bottom-width |
BorderBottomWidth |
| Border-color |
BorderColor |
| Border-left |
BorderLeft |
| Border-left-color |
BorderLeftColor |
| Border-left-style |
BorderLeftStyle |
| Border-left-width |
BorderLeftWidth |
| Border-right |
BorderRight |
| Border-right-color |
BorderRightColor |
| Border-right-style |
BorderRightStyle |
| Border-right-width |
BorderRightWidth |
| Border-style |
BorderStyle |
| Border-top |
BorderTop |
| Border-top-color |
BorderTopColor |
| Border-top-style |
BorderTopStyle |
| Border-top-width |
BorderTopWidth |
| Border-width |
BorderWidth |
| Clear |
Clear |
| Float |
FloatStyle |
| Margin |
Margin |
| Margin-bottom |
MarginBottom |
| Margin-left |
MarginLeft |
| Margin-right |
MarginRight |
| Margin-top |
MarginTop |
| Padding |
Padding |
| Padding-bottom |
PaddingBottom |
| Padding-left |
PaddingLeft |
| Padding-right |
PaddingRight |
| Padding-top |
PaddingTop |
|
| Comparison of color and background tags and attributes |
| CSS syntax (Case Insensitive) |
JavaScript syntax (case sensitive) |
| Background |
Background |
| Background-attachment |
BackgroundAttachment |
| Background-color |
BackgroundColor |
| Background-image |
BackgroundImage |
| Background-position |
BackgroundPosition |
| Background-repeat |
BackgroundRepeat |
| Color |
Color |
|
| Comparison between style labels and attributes |
| CSS syntax (Case Insensitive) |
JavaScript syntax (case sensitive) |
| Display |
Display |
| List-style-type |
ListStyleType |
| List-style-image |
ListStyleImage |
| List-style-position |
ListStylePosition |
| List-style |
ListStyle |
| White-space |
WhiteSpace |
|
| Text style label and attribute comparison |
| CSS syntax (Case Insensitive) |
JavaScript syntax (case sensitive) |
| Font |
Font |
| Font-family |
FontFamily |
| Font-size |
FontSize |
| Font-style |
FontStyle |
| Font-variant |
FontVariant |
| Font-weight |
FontWeight |
|
| Text tag and attribute comparison |
| CSS syntax (Case Insensitive) |
JavaScript syntax (case sensitive) |
| Letter-spacing |
LetterSpacing |
| Line-break |
LineBreak |
| Line-height |
LineHeight |
| Text-align |
TextAlign |
| Text-decoration |
TextDecoration |
| Text-indent |
TextIndent |
| Text-justify |
TextJustify |
| Text-transform |
TextTransform |
| Vertical-align |
VerticalAlign |