Help:Tablas

From mediawiki.org
This page is a translated version of the page Help:Tables and the translation is 79% complete.
Outdated translations are marked like this.
PD Nota: Cuando editas esta página, aceptas liberar tu contribución bajo la licencia CC0. Para más información mira las páginas de ayuda de dominio público. PD
Para la estructura de la base de datos de MediaWiki, ver Manual:Database layout

Las Tablas se pueden crear en páginas wiki. Como regla general, es mejor evitar el uso de una tabla a menos que realmente la necesites, pues la inclusión de tablas complica la edición de la página.[1]

Sumario de formato de tablas en código wiki

{| Inicio de la tabla, requerido
|+ subtítulo de la tabla, opcional; sólo entre inicio de tabla y la primera fila
|- fila, opcional en la primera fila -- el software wiki lo asume en la primera fila
! encabezado de la celda, opcional. Si hay celdas consecutivas de encabezado en la misma línea, deben separarse con una marca doble (!!) o comenzar en nuevas líneas, cada una con su propia marca (!).
| encabezado de la celda, opcional. i hay celdas consecutivas de datos en la misma línea, deben separarse con una marca doble (||) o comenzar en nuevas líneas, cada una con su propia marca (|).
|} Fin de la tabla, requerido
  • Las marcas anteriores deben comenzar en una nueva línea excepto el doble || y !! para opcionalmente agregar celdas consecutivas a una línea. Sin embargo, los espacios en blanco al comienzo de una línea se ignoran.
  • ==Atributos HTML== Cada marca, excepto el cierre de tabla, acepta opcionalmente uno o mas atributos HTML Los atributos deben encontrarse en la misma linea que la marca. Separa los atributos con un espacio.
    • Cells and caption (| or ||, ! or !!, and |+) hold content.

Separe cualquier atributo del contenido con una barra simple (|). El contenido de la celda se puede continuar aún en diferente línea

    • Los marcadores de tabla y fila ({| and |-) no pueden contener contenido directamente. No agregar barra (|) despues de los atributos opcionales. Si por error agrega una barra después de los atributos para una marca de tabla o marca de fila, el analizador lo eliminara y el atributo final, si lo hay, se aplicara a la barra incorrecta
  • El contenido puede (a) continuar en su propia marca de celda en la misma linea despues de cualquier atributo HTML opcional, ó (b) en las lineas debajo de la marca de la celda El contenido que utiliza "wiki markup" que necesita iniciarse en una nueva linea, como listas, encabezados o tablas anidadas, debe encontrarse en su propia linea nueva.
    • Caracter barra como contenido Para insertar un carácter de barra como contenido en una tabla (|), use el formato de marcaje de escape <nowiki>|</nowiki>


Conceptos básicos

Create a table with editor toolbar

In wikitext editor, place the caret where you want to insert a table. Then, in the toolbar, press “Avanzado”, then choose Tabla button. A dialog opens.

From the dialog, you can choose whether to enable a table header row, to stylize the table with border and to make the table sortable. A preview example is displayed. You can also set row and column counts you need. Then, press “Insertar” button.

By default, the following code is generated:

Wikicode:
{| class="wikitable" style="margin:auto"
|+ Texto de la leyenda
|-
! Texto de cabecera !! Texto de cabecera !! Texto de cabecera
|-
| Ejemplo || Ejemplo || Ejemplo
|-
| Ejemplo || Ejemplo || Ejemplo
|-
| Ejemplo || Ejemplo || Ejemplo
|}
Result:
Texto de la leyenda
Texto de cabecera Texto de cabecera Texto de cabecera
Ejemplo Ejemplo Ejemplo
Ejemplo Ejemplo Ejemplo
Ejemplo Ejemplo Ejemplo

Minimal syntax

La siguiente tabla carece de bordes y de un buen espaciado, pero muestra la estructura de tabla en el formato wiki más simple.

Usted escribe Usted obtiene
{|
|Naranja
|Manzana
|-
|Pan
|Pastel
|-
|Mantequilla
|Helado
|}
Naranja Manzana
Pan Pastel
Mantequilla Helado

Las celdas de la misma fila pueden listarse en una línea separándolas con || (dos barras verticales). Si el texto en la celda debe contener un salto de linea, puede utilizar ‎<br /> también

Usted escribe Usted obtiene
{|
|Naranja||Manzana||más…
|-
|Pan||Pastel||más
|-
|Mantequilla||Helado<br/>cremoso||y<br/>mas
|}
Naranja Manzana más
Pan Pastel más
Mantequilla Helado
y
más

Los espacios extras entre celdas en el "wiki markup", como en el mostrado abajo, no afecta el diseño de la tabla.

Usted escribe Usted obtiene
{|
|  Naranja || Manzana || más
|-
|   Pan || Pastel || más
|-
|   Mantequilla || Helado || y más
|}
Naranja Manzana más
Pan Pastel más
Mantequilla Helado y más

Usted puede tener textos mas largos o sintaxis wiki mas compleja dentro de las celdas también:

Usted escribe Usted obtiene
{|
|Lorem ipsum dolor sit amet,
consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt
ut labore et dolore magna aliquyam erat,
sed diam voluptua.

At vero eos et accusam et justo duo dolores
et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum
dolor sit amet.
|
* Lorem ipsum dolor sit amet
* consetetur sadipscing elitr
* sed diam nonumy eirmod tempor invidunt
|}
Lorem ipsum dolor sit amet,

consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

  • Lorem ipsum dolor sit amet
  • consetetur sadipscing elitr
  • sed diam nonumy eirmod tempor invidunt

Encabezados de tabla

Los encabezados de tabla pueden ser creados utilizando el simbolo de exclamacion "!" en vez de la barra vertical "|" Los encabezados usualmente se muestran con negrita y centrados de forma predeterminada.

Usted escribe Usted obtiene
{|
! style="text-align:left;"| Elemento
! Monto
! Costo
|-
|Naranja
|10
|7.00
|-
|Pan
|4
|3.00
|-
|Mantequilla
|1
|5.00
|-
!Total
|
|15.00
|}
Elemento Monto Costo
Naranja 10 7.00
Pan 4 3.00
Mantequilla 1 5.00
Total 15.00
Cuando se utilizan atributos en el 'elemento' encabezado, se utiliza una '|' para separación. No un carácter de exclamación '!'

Leyenda

Una leyenda de tabla puede ser agregada a la cabeza de cualquier tabla como se muestra a continuación.

Usted escribe Usted obtiene
{|
|+Complementos alimenticios
|-
|Naranja
|Manzana
|-
|Pan
|Pastel
|-
|Mantequilla
|Helado
|}
Complementos alimenticios
Naranja Manzana
Pan Pastel
Mantequilla Helado

class="wikitable"

Un estilo básico (fondo gris claro, bordes, espaciado entre celdas y alineación izquierda) se pueden lograr agregando la clase wikitable (class="wikitable")

Usted escribe Usted obtiene
{| class="wikitable"
|+Complementos alimenticios
|-
|Naranja
|Manzana
|-
|Pan
|Pastel
|-
|Mantequilla
|Helado
|}
Complementos alimenticios
Naranja Manzana
Pan Pastel
Mantequilla Helado

Combinación HTML de celdas en columna y fila

Ustede puede utilizar los atributos HTML colspan y rowspan en las celdas para realizar combinaciones de celdas en un diseño avanzado.

Usted escribe Usted obtiene
{| class="wikitable"
!colspan="6"|Lista de compras
|-
|rowspan="2"|Pan y Mantequilla
|Pastel
|Panecillos
|Pan Danés
|colspan="2"|Cuerno
|-
|Queso
|colspan="2"|Helado
|Mantequilla
|Yogur
|}
Lista de compras
Pan y Mantequilla Pastel Panecillos Pan Danés Cuerno
Queso Helado Mantequilla Yogur

Atributos HTML

Puedes añadir atributos HTML a las tablas. Para información detallada del tema, visite la página de especificación de tablas de HTML 4.01 de W3C.

Atributos en las tablas

Si se coloca atributos después del código de inicio de la tabla ({|), se aplicarán a toda la tabla.

Usted escribe Usted obtiene
{| class="wikitable" style="text-align: center; color: green;"
|Naranja
|Manzana
|12,333.00
|-
|Pan
|Pastel
|500.00
|-
|Mantequilla
|Helado
|1.00
|}
Naranja Manzana 12,333.00
Pan Pastel 500.00
Mantequilla Helado 1.00

Atributos en celdas

Usted puede incluir atributos en celdas individuales. Por ejemplo, los números suelen leerse mejor si se alinean a la derecha.

Usted escribe Usted obtiene
{| class="wikitable"
| Naranja
| Manzana
| style="text-align:right;" | 12,333.00
|-
| Pan
| Pastel
| style="text-align:right;" | 500.00
|-
| Mantequilla
| Helado
| style="text-align:right;" | 1.00
|}
Naranja Manzana 12,333.00
Pan Pastel 500.00
Mantequilla Helado 1.00

También puede usar atributos de celda cuando está poniendo varias celdas en una sola línea. Obsérvese que las celdas se separan con || y dentro de cada celda los atributos y valores se separan con |.

Escribes Obtienes
{| class="wikitable"
| Naranja || Manzana     || style="text-align:right;" | 12,333.00
|-
| Pan || Pastel       || style="text-align:right;" | 500.00
|-
| Mantequilla || Helado || style="text-align:right;" | 1.00
|}
Naranja Manzana 12,333.00
Pan Pastel 500.00
Mantequilla Helado 1.00

Atributos en filas

Puedes poner atributos en filas individuales.

Escribes Obtienes
{| class="wikitable"
| Naranja
| Manzana
| style="text-align:right;"| 12,333.00
|-
| Pan
| Pastel
| style="text-align:right;"| 500.00
|- style="font-style: italic; color: green;"
| Mantequilla
| Helado
| style="text-align:right;"| 1.00
|}
Naranja Manzana 12,333.00
Pan Pastel 500.00
Mantequilla Helado 1.00

Atributos

Se pueden añadir atributos a los encabezados y a los subtítulos como se indica a continuación.

Escribes Obtienes
{| class="wikitable"
|+ style="caption-side:bottom; color:#e76700;"|Complementos alimenticios
|-
! style="color:green" | Fruits
! style="color:red" | Fats
|-
|Naranja
|Mantequilla
|-
|Pan
|Pastel
|-
|Manzana
|Helado
|}
Complementos alimenticios
Fruits Fats
Naranja Mantequilla
Pan Pastel
Manzana Helado

Ancho de borde

Si el atributo "border-width:" (ancho de borde) tiene únicamente un numero, aplica este valor a los cuatro lados:

Escribes Obtienes
{|style="border-style: solid; border-width: 20px"
|
Hola
|}

Hola

Si el atributo "border-width:" (ancho de borde) se establece con 4 numeros, aplica los valores en el orden siguiente arriba, derecha, abajo, izquierda de cada uno de los lados. Este orden no cambia.

Escribes Obtienes
{|style="border-style: solid; border-width: 10px 20px 100px 0"
|
Hola
|}

Hola

Cuando se especifican menos de 4 valores, el valor para izquierda se establece de forma predeterminada tomando el valor de la derecha, el valor de abajo toma por defecto el valor de arriba, y el valor de derecha toma por defecto el valor de arriba.
  • three values i.e. top, right, bottom: then the default value for left is the one of right (second value). Width is then the same on left and right side.
  • two values i.e. top, right: then the default value for bottom is the one of top (first value), and left by default is assigned the value of right (second value). Width on top is then the same as on bottom; width on left is the same as on right.
  • one value i.e. top: then the default value for right is the one of top and it is the same for bottom and left. The fourth width are the same and build a regular border. This is a writing shortcut.

Otro método para definir los anchos de los cuatro lados de una celda es utilizando "border-left", "border-right", "border-top" y "border-bottom":

Escribes Obtienes
{|style="border-left:solid 10px black;border-right:solid 20px black;border-top:solid 30px black;border-bottom:solid 40px black;" align="center"
|
Hola
|}

Hola

*Los atributos HTML (como "width=", "border=", "cellspacing=", "cellpadding=") no necesitan que se especifique una unidad de medida con el numero, puesto que se asume que la unidad de medida es el pixel. También hay inválidos en HTML 5.

"Cellpadding" is for setting the space between the cell wall and the cell content.

[2] Las propiedades de los estilos CSS (que anulan los atributos HTML) requieren una unidad de medida especifica (si el valor no es cero) como px para indicar pixeles.

Con atributos HTML y estilos CSS

Es posible añadir atributos de estilo CSS, con o sin otros atributos HTML.

Escribes Obtienes
{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"
|Naranja
|Manzana
|-
|Pan
|Pastel
|-
|Mantequilla
|Helado
|}
Naranja Manzana
Pan Pastel
Mantequilla Helado

Padding

It represents the internal margin between the contents and the border of the cell.

You type You get
{|class=wikitable
| style="padding: 10px" | Ejemplo de style="padding:10px"
|-
| style="padding: 50px" | Ejemplo de style="padding:50px"<br/><br/>Specify the padding on '''EACH CELL'''
|-
| style="padding:100px" | Ejemplo de style="padding:100px"
|}
Ejemplo de style="padding:10px"
Ejemplo de style="padding:50px"

Specify the padding on EACH CELL
Ejemplo de style="padding:100px"

Ancho de columna

El ancho de columna puede ser agregado como se muestra a continuación.

Escribes

{| class="wikitable" style="width: 85%;"
| colspan="2" | This column width is 85% of the screen width
|-
| style="width: 30%"| '''This column is 30% counted from 85% of the screen width'''
| style="width: 70%"| '''This column is 70% counted from 85% of the screen width'''
|}

Obtienes

This column width is 85% of the screen width
This column is 30% counted from 85% of the screen width This column is 70% counted from 85% of the screen width

Accessibility of table header cells

Table header cells do not explicitly specify which table data cells they apply to (those on their right on the same row, or those below them on the same column). When the table is rendered in a visual 2D environment, this is usually easy to infer.

However when tables are rendered on non-visual media, you can help the browser to determine which table header cell applies to the description of any selected cell (in order to repeat its content in some accessibility helper) using a scope="row" or scope="col" attribute on table header cells. In most cases with simple tables, you'll use scope="col" on all header cells of the first row, and scope="row" on the first cell of the following rows:

Escribes Obtienes
{| class="wikitable"
|-
! scope="col"| Elemento
! scope="col"| Cantidad
! scope="col"| Precio
|-
! scope="row"| Pan
| 0.3 kg
| $0.65
|-
! scope="row"| Mantequilla
| 0.125 kg
| $1.25
|-
! scope="row" colspan="2"| Total
| $1.90
|}
Elemento Cantidad Precio
Pan 0.3 kg $0.65
Mantequilla 0.125 kg $1.25
Total $1.90

Alignment

Table alignment

Table alignment is achieved by using CSS. The table alignment is controlled by margins. A fixed margin on one side will make the table to be aligned to that side, if on the opposite side the margin is defined as auto. To have a table center aligned, you should set both margins to auto

For example, a right-aligned table:

Escribes Obtienes
{| class="wikitable" style="margin-left: auto; margin-right: 0px;"
| Naranja
| Manzana
|-
| Pan
| Pastel
|-
| Mantequilla
| Helado
|}

Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi
enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea
commodo consequat.
Naranja Manzana
Pan Pastel
Mantequilla Helado

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

And a center-aligned table:

Escribes Obtienes
{| class="wikitable" style="margin: auto;"
| Naranja
| Manzana
|-
| Pan
| Pastel
|-
| Mantequilla
| Helado
|}

Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi
enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea
commodo consequat.
Naranja Manzana
Pan Pastel
Mantequilla Helado

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Table floating around text

If you align a table to the right or the left side of the page, the text that comes after the table starts at the end of it, leaving an empty space around the table. You can make the text to be wrapped around the table by making the table to float around the text instead of just aligning it. This can be achieved using the float CSS attribute, which can specify where the table floats to the right side or to the left. When using float, margins doesn't control table alignment and can be used to specify the margin between the table and the surrounding text.

Escribes Obtienes
{| class="wikitable" style="float:right; margin-left: 10px;"
| Naranja
| Manzana
|-
| Pan
| Pastel
|-
| Mantequilla
| Helado
|}

Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi
enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea
commodo consequat. Duis autem vel eum iriure dolor
in hendrerit in vulputate velit esse molestie consequat,
vel illum dolore eu feugiat nulla facilisis at vero
eros et accumsan et iusto odio dignissim qui blandit
praesent luptatum zzril delenit augue duis dolore te
feugait nulla facilisi.
Naranja Manzana
Pan Pastel
Mantequilla Helado

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

Alineación de contenidos de la celda

The alignment of cell contents can be controlled with 2 different CSS properties: text-align and vertical-align. text-align can be specified at the table, row or individual cells, while vertical-align only can be specified at individual rows or cells.

Escribes You get
{| class="wikitable"
|- style="vertical-align:top;"
| style="height:100px; width:100px; text-align:left;" | A
| style="height:100px; width:100px; text-align:center;" | B
| style="height:100px; width:100px; text-align:right;" | C
|- style="vertical-align:middle;"
| style="height:100px; width:100px; text-align:left;" | D
| style="height:100px; width:100px; text-align:center;" | E
| style="height:100px; width:100px; text-align:right;" | F
|- style="vertical-align:bottom;"
| style="height:100px; width:100px; text-align:left;" | G
| style="height:100px; width:100px; text-align:center;" | H
| style="height:100px; width:100px; text-align:right;" | I
|}
A B C
D E F
G H I


Advertencias

Números negativos

Si comienzas una celda en una nueva línea con un número negativo con un signo menos (o un parámetro que lo muestre como número negativo) la tabla puede alterarse, porque los caracteres |- se interpretarán como formato wiki para la fila de la tabla, no la celda. Para evitar esto, inserta un espacio antes del signo (| -6) o utiliza una celda en la misma línea (||-6).

CSS frente a atributos

Es posible que algunos navegadores de texto muestren los bordes de la tabla de forma incorrecta si se especificaron mediante CSS al mismo tiempo que con un atributo del borde.

Atributos comunes para columnas, grupos de columna y grupos de fila

The MediaWiki syntax for tables currently offers no support for specifying common attributes for columns (with the HTML element ‎<col />), column groups (HTML element ‎<colgroup>‎</colgroup>) and row groups (HTML elements ‎<thead>‎</thead>, ‎<tbody>‎</tbody> and ‎<tfoot>‎</tfoot>). Those standard HTML elements are not accepted even in their HTML or XHTML syntax.

All the rows and cells (header or data) of the table are rendered within a single implicit row group (HTML element ‎<tbody>‎</tbody>) without any attributes or styles.

Tables and the Visual Editor (VE)

See also: Ayuda:EditorVisual/Guía de usuario

See Phab: T108245: "Fully support basic table editing in the visual editor". See the list of tasks. Finished tasks are struck. It can be difficult to figure out from the technical language there what exactly has been improved, or what features have been added. Please add explanatory info below.

Can now move or delete columns and rows

Click on a column or row header. Then click on the arrow. From the popup menu click on "Move" or "Delete".

Insert blank row or column

From the same popup menu click on "Insert".

Copy table from web page to Visual Editor

It is possible to copy and paste a table from a web page directly into the Visual Editor (VE). To do so safely, use a sandbox and check the table for proper coding in wikitext source mode and proper display in the Visual Editor and in preview mode.

Helping tools

  • Excel2Wiki allows you to copy a spreadsheet from Excel, Apache OpenOffice, LibreOffice, or Gnumeric to convert it into wikicode table.

Véase también

Notas

  1. Las tablas se pueden crear en páginas wiki usando directamente ciertos elementos de tablas XHTML, o bien usando formato de código wiki para definir la tabla. Los elementos de tabla XHTML están bien descritos en varios sitios web y no se discutirán aquí. La ventaja de usar el código wiki es que la tabla se construye mediante caracteres que tienden a hacer más fácil la percepción de la estructura de la tabla en la vista de edición del artículo, en comparación con los elementos de tabla XHTML.
  2. HTML table cellpadding Attribute