A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.
To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).
Presentational elements and attributes: Difference between revisions
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
</pre> | </pre> | ||
...then clearly the intent of "Welcome to my page" is a heading, and thus h1 should be used: | ...then clearly the intent of "Welcome to my page" is to represent a heading, and thus h1 should be used: | ||
<pre> | <pre> |
Revision as of 23:03, 24 June 2009
The HTML 5 spec lists some obsolete elements and attributes, some of which the advice given is "Use CSS instead.".
This page is intended to give advice about specific CSS features that can be used instead of each such element or attribute.
You should think about whether there is a semantic element that matches the intent of your use of a presentational element. If there is such an element, you should use it, and if it doesn't already have a default styling that you like, then you can use CSS from the tables below to make it look like you want. You may also have to reset any other properties that some elements have by default. If there is no appropriate semantic element for the purpose, then you should probably use div or span instead.
For example, if you have a page such as:
<body> <big><strong>Welcome to my page</strong></big> <p>Hello world.</p> ...
...then clearly the intent of "Welcome to my page" is to represent a heading, and thus h1 should be used:
<body> <h1>Welcome to my page</h1> <p>Hello world.</p> ...
You can then style the h1 so that it looks like the first example by using:
h1 { font-size:larger; margin:0 }
Presentational elements
Element | CSS equivalent |
---|---|
basefont | 'font-size', 'font-family' and 'color' on body |
big | 'font-size:larger' |
blink | 'text-decoration:blink' |
center | 'text-align:center' and 'margin-left:auto; margin-right:auto' on descendant blocks |
font | 'font-size', 'font-family' and 'color' |
marquee | CSS transitions and animations |
s | 'text-decoration:line-through' |
spacer | 'margin', 'padding' |
strike | 'text-decoration:line-through' |
tt | 'font-family:monospace' |
u | 'text-decoration:undefline' |
Presentational attributes
Attribute | CSS equivalent |
---|---|
alink on body elements | 'color' on :link:active, :visited:active |
background on body elements | 'background-image' on body |
bgcolor on body elements | 'background-color' on body |
link on body elements | 'color' on :link |
text on body elements | 'color' on body |
vlink on body elements | 'color' on :visited |
clear on br elements | 'clear' (or other techniques to clear floats) |
align on caption elements | 'caption-side', 'text-align' |
align on col elements | 'text-align' on the appropriate th/td |
char on col elements | - |
charoff on col elements | - |
valign on col elements | 'vertical-align' on the appropriate th/td |
width on col elements | 'width' on col |
align on div elements | 'text-align' and 'margin-left:auto' and/or 'margin-right:auto' on descendant blocks |
compact on dl elements | - |
align on hr elements | 'margin-left:auto' and/or 'margin-right:auto' on hr |
noshade on hr elements | 'border-style:solid' on hr |
size on hr elements | 'border-width' or 'height' on hr |
width on hr elements | 'width' on hr |
align on h1—h6 elements | 'text-align' on h1-h6 |
align on iframe elements | 'float' on iframe |
frameborder on iframe elements | 'border' on iframe |
marginheight on iframe elements | 'margin-top' and 'margin-bottom' on body in the containing document |
marginwidth on iframe elements | 'margin-left' and 'margin-right' on body in the containing document |
scrolling on iframe elements | 'overflow' on the root element in the containing document |
align on input elements | 'float' or 'vertical-align' on input |
align on img elements | 'float' on img |
border on img elements | 'border' on img |
hspace on img elements | 'margin-left' and 'margin-right' on img |
vspace on img elements | 'margin-top' and 'margin-bottom' on img |
align on legend elements | - |
type on li elements | 'list-style-type' on li |
compact on menu elements | - |
align on object elements | 'float' on object |
border on object elements | 'border' on object |
hspace on object elements | 'margin-left' and 'margin-right' on object |
vspace on object elements | 'margin-top' and 'margin-bottom' on object |
compact on ol elements | - |
type on ol elements | 'list-style-type' on ol |
align on p elements | 'text-align' on p |
width on pre elements | 'width' on pre |
align on table elements | 'margin-left:auto' and/or 'margin-right:auto' on table |
bgcolor on table elements | 'background-color' on table |
border on table elements | 'border-width' on table and on the table's td and th |
cellpadding on table elements | 'padding' on the table's td and th |
cellspacing on table elements | 'border-spacing' on table |
frame on table elements | 'border-color:black' and 'border-style' on table |
rules on table elements | 'border-color:black' and 'border-style' on the table's appropriate elements |
width on table elements | 'width' on table |
align on tbody, thead, and tfoot elements | 'text-align' on tbody, thead and tfoot and 'margin-left:auto' and/or 'margin-right:auto' on descendant blocks |
char on tbody, thead, and tfoot elements | - |
charoff on tbody, thead, and tfoot elements | - |
valign on tbody, thead, and tfoot elements | 'vertical-align' on tbody, thead and tfoot |
align on td and th elements | 'text-align' on td and th and 'margin-left:auto' and/or 'margin-right:auto' on descendant blocks |
bgcolor on td and th elements | 'background-color' on td and th |
char on td and th elements | - |
charoff on td and th elements | - |
height on td and th elements | 'height' on td and th |
nowrap on td and th elements | 'white-space:nowrap' on td and th |
valign on td and th elements | 'vertical-align' on td and th |
width on td and th elements | 'width' on td and th |
align on tr elements | 'text-align' on tr and 'margin-left:auto' and/or 'margin-right:auto' on descendant blocks |
bgcolor on tr elements | 'background-color' on tr |
char on tr elements | - |
charoff on tr elements | - |
valign on tr elements | 'vertical-align' on tr |
compact on ul elements | - |
type on ul elements | 'list-style-type' on ul |